Skip to content

Commit

Permalink
Fix syntax error in test
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-mc committed Aug 21, 2024
1 parent 6231211 commit 3552936
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions go/ql/test/library-tests/semmle/go/Function/genericFunctions.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,18 @@ func generic_functions() {
// Slice write
sliceVar[0] = -1

// Access a map through two type aliases
aliasedMap := T2{"key": []string{"value"}}
// Access a map through two named types
mapThroughNamedTypes := DefinedType2{"key": []string{"value"}}
// Map read
_ = aliasedMap["key"]
_ = mapThroughNamedTypes["key"]
// Map write
aliasedMap["key"][0] = "new value"
mapThroughNamedTypes["key"][0] = "new value"
// Access a map through two type aliases and two named types
mapThroughAliasedTypes := AliasType2{"key": []string{"value"}}
// Map read
_ = mapThroughAliasedTypes["key"]
// Map write
mapThroughAliasedTypes["key"][0] = "new value"
}

type GenericStruct1[TP104 interface{}] struct {
Expand Down
2 changes: 2 additions & 0 deletions go/ql/test/library-tests/semmle/go/Types/Aliases.ql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ string getQualifiedNameIfExists(Type t) {
if exists(t.getQualifiedName()) then result = t.getQualifiedName() else result = t.getName()
}

predicate foo(Type t, string s) { not exists(t.getQualifiedName()) and s = t.pp() }

Check warning

Code scanning / CodeQL

Dead code Warning test

This code is never used, and it's not publicly exported.

from AliasType at
where at.hasLocationInfo(_, _, _, _, _)
select getQualifiedNameIfExists(at), getQualifiedNameIfExists(at.getRhs()),
Expand Down

0 comments on commit 3552936

Please sign in to comment.