From f6f6a5ccc6027bf04d30c1fe32a7dc4d16072504 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Tue, 20 May 2025 02:11:05 +0100 Subject: [PATCH] Only list type params in test files This will make the test results not depend on the version of the standard library being used, which means we don't have to update it with each new release. --- .../semmle/go/Function/TypeParamType.expected | 206 ------------------ .../semmle/go/Function/TypeParamType.ql | 6 +- 2 files changed, 5 insertions(+), 207 deletions(-) diff --git a/go/ql/test/library-tests/semmle/go/Function/TypeParamType.expected b/go/ql/test/library-tests/semmle/go/Function/TypeParamType.expected index 27a0d5171dec..bda7c1517975 100644 --- a/go/ql/test/library-tests/semmle/go/Function/TypeParamType.expected +++ b/go/ql/test/library-tests/semmle/go/Function/TypeParamType.expected @@ -20,10 +20,6 @@ numberOfTypeParameters | genericFunctions.go:152:6:152:36 | multipleAnonymousTypeParamsType | 3 | | genericFunctions.go:154:51:154:51 | f | 3 | #select -| cmp.Compare | 0 | T | Ordered | -| cmp.Less | 0 | T | Ordered | -| cmp.Or | 0 | T | comparable | -| cmp.isNaN | 0 | T | Ordered | | codeql-go-tests/function.EdgeConstraint | 0 | Node | interface { } | | codeql-go-tests/function.Element | 0 | S | interface { } | | codeql-go-tests/function.GenericFunctionInAnotherFile | 0 | T | interface { } | @@ -57,205 +53,3 @@ numberOfTypeParameters | codeql-go-tests/function.multipleAnonymousTypeParamsType.f | 0 | _ | interface { } | | codeql-go-tests/function.multipleAnonymousTypeParamsType.f | 1 | _ | interface { string } | | codeql-go-tests/function.multipleAnonymousTypeParamsType.f | 2 | _ | interface { } | -| github.com/anotherpkg.GenericFunctionInAnotherPackage | 0 | T | interface { } | -| internal/abi.Escape | 0 | T | interface { } | -| internal/bytealg.HashStr | 0 | T | interface { string \| []uint8 } | -| internal/bytealg.HashStrRev | 0 | T | interface { string \| []uint8 } | -| internal/bytealg.IndexRabinKarp | 0 | T | interface { string \| []uint8 } | -| internal/bytealg.LastIndexRabinKarp | 0 | T | interface { string \| []uint8 } | -| internal/poll.ignoringEINTR2 | 0 | T | interface { } | -| internal/runtime/atomic.Pointer.CompareAndSwap | 0 | T | interface { } | -| internal/runtime/atomic.Pointer.CompareAndSwapNoWB | 0 | T | interface { } | -| internal/runtime/atomic.Pointer.Load | 0 | T | interface { } | -| internal/runtime/atomic.Pointer.Store | 0 | T | interface { } | -| internal/runtime/atomic.Pointer.StoreNoWB | 0 | T | interface { } | -| internal/sync.HashTrieMap.All | 0 | K | comparable | -| internal/sync.HashTrieMap.All | 1 | V | interface { } | -| internal/sync.HashTrieMap.CompareAndDelete | 0 | K | comparable | -| internal/sync.HashTrieMap.CompareAndDelete | 1 | V | interface { } | -| internal/sync.HashTrieMap.CompareAndSwap | 0 | K | comparable | -| internal/sync.HashTrieMap.CompareAndSwap | 1 | V | interface { } | -| internal/sync.HashTrieMap.Delete | 0 | K | comparable | -| internal/sync.HashTrieMap.Load | 0 | K | comparable | -| internal/sync.HashTrieMap.Load | 1 | V | interface { } | -| internal/sync.HashTrieMap.LoadAndDelete | 0 | K | comparable | -| internal/sync.HashTrieMap.LoadAndDelete | 1 | V | interface { } | -| internal/sync.HashTrieMap.LoadOrStore | 0 | K | comparable | -| internal/sync.HashTrieMap.LoadOrStore | 1 | V | interface { } | -| internal/sync.HashTrieMap.Range | 0 | K | comparable | -| internal/sync.HashTrieMap.Range | 1 | V | interface { } | -| internal/sync.HashTrieMap.Store | 0 | K | comparable | -| internal/sync.HashTrieMap.Store | 1 | V | interface { } | -| internal/sync.HashTrieMap.Swap | 0 | K | comparable | -| internal/sync.HashTrieMap.Swap | 1 | V | interface { } | -| internal/sync.HashTrieMap.find | 0 | K | comparable | -| internal/sync.HashTrieMap.find | 1 | V | interface { } | -| internal/sync.HashTrieMap.iter | 0 | K | comparable | -| internal/sync.HashTrieMap.iter | 1 | V | interface { } | -| internal/sync.entry | 0 | K | comparable | -| internal/sync.entry | 1 | V | interface { } | -| internal/sync.entry.compareAndDelete | 0 | K | comparable | -| internal/sync.entry.compareAndDelete | 1 | V | interface { } | -| internal/sync.entry.compareAndSwap | 0 | K | comparable | -| internal/sync.entry.compareAndSwap | 1 | V | interface { } | -| internal/sync.entry.loadAndDelete | 0 | K | comparable | -| internal/sync.entry.loadAndDelete | 1 | V | interface { } | -| internal/sync.entry.lookup | 0 | K | comparable | -| internal/sync.entry.lookup | 1 | V | interface { } | -| internal/sync.entry.lookupWithValue | 0 | K | comparable | -| internal/sync.entry.lookupWithValue | 1 | V | interface { } | -| internal/sync.entry.swap | 0 | K | comparable | -| internal/sync.entry.swap | 1 | V | interface { } | -| internal/sync.newEntryNode | 0 | K | comparable | -| internal/sync.newEntryNode | 1 | V | interface { } | -| iter.Pull | 0 | V | interface { } | -| iter.Pull2 | 0 | K | interface { } | -| iter.Pull2 | 1 | V | interface { } | -| iter.Seq | 0 | V | interface { } | -| iter.Seq2 | 0 | K | interface { } | -| iter.Seq2 | 1 | V | interface { } | -| os.doInRoot | 0 | T | interface { } | -| os.ignoringEINTR2 | 0 | T | interface { } | -| reflect.rangeNum | 1 | N | interface { int64 \| uint64 } | -| runtime.AddCleanup | 0 | T | interface { } | -| runtime.AddCleanup | 1 | S | interface { } | -| runtime.fandbits | 0 | F | floaty | -| runtime.fmax | 0 | F | floaty | -| runtime.fmin | 0 | F | floaty | -| runtime.forbits | 0 | F | floaty | -| runtime.noEscapePtr | 0 | T | interface { } | -| slices.All | 0 | Slice | interface { ~[]E } | -| slices.All | 1 | E | interface { } | -| slices.AppendSeq | 0 | Slice | interface { ~[]E } | -| slices.AppendSeq | 1 | E | interface { } | -| slices.Backward | 0 | Slice | interface { ~[]E } | -| slices.Backward | 1 | E | interface { } | -| slices.BinarySearch | 0 | S | interface { ~[]E } | -| slices.BinarySearch | 1 | E | Ordered | -| slices.BinarySearchFunc | 0 | S | interface { ~[]E } | -| slices.BinarySearchFunc | 1 | E | interface { } | -| slices.BinarySearchFunc | 2 | T | interface { } | -| slices.Chunk | 0 | Slice | interface { ~[]E } | -| slices.Chunk | 1 | E | interface { } | -| slices.Clip | 0 | S | interface { ~[]E } | -| slices.Clip | 1 | E | interface { } | -| slices.Clone | 0 | S | interface { ~[]E } | -| slices.Clone | 1 | E | interface { } | -| slices.Collect | 0 | E | interface { } | -| slices.Compact | 0 | S | interface { ~[]E } | -| slices.Compact | 1 | E | comparable | -| slices.CompactFunc | 0 | S | interface { ~[]E } | -| slices.CompactFunc | 1 | E | interface { } | -| slices.Compare | 0 | S | interface { ~[]E } | -| slices.Compare | 1 | E | Ordered | -| slices.CompareFunc | 0 | S1 | interface { ~[]E1 } | -| slices.CompareFunc | 1 | S2 | interface { ~[]E2 } | -| slices.CompareFunc | 2 | E1 | interface { } | -| slices.CompareFunc | 3 | E2 | interface { } | -| slices.Concat | 0 | S | interface { ~[]E } | -| slices.Concat | 1 | E | interface { } | -| slices.Contains | 0 | S | interface { ~[]E } | -| slices.Contains | 1 | E | comparable | -| slices.ContainsFunc | 0 | S | interface { ~[]E } | -| slices.ContainsFunc | 1 | E | interface { } | -| slices.Delete | 0 | S | interface { ~[]E } | -| slices.Delete | 1 | E | interface { } | -| slices.DeleteFunc | 0 | S | interface { ~[]E } | -| slices.DeleteFunc | 1 | E | interface { } | -| slices.Equal | 0 | S | interface { ~[]E } | -| slices.Equal | 1 | E | comparable | -| slices.EqualFunc | 0 | S1 | interface { ~[]E1 } | -| slices.EqualFunc | 1 | S2 | interface { ~[]E2 } | -| slices.EqualFunc | 2 | E1 | interface { } | -| slices.EqualFunc | 3 | E2 | interface { } | -| slices.Grow | 0 | S | interface { ~[]E } | -| slices.Grow | 1 | E | interface { } | -| slices.Index | 0 | S | interface { ~[]E } | -| slices.Index | 1 | E | comparable | -| slices.IndexFunc | 0 | S | interface { ~[]E } | -| slices.IndexFunc | 1 | E | interface { } | -| slices.Insert | 0 | S | interface { ~[]E } | -| slices.Insert | 1 | E | interface { } | -| slices.IsSorted | 0 | S | interface { ~[]E } | -| slices.IsSorted | 1 | E | Ordered | -| slices.IsSortedFunc | 0 | S | interface { ~[]E } | -| slices.IsSortedFunc | 1 | E | interface { } | -| slices.Max | 0 | S | interface { ~[]E } | -| slices.Max | 1 | E | Ordered | -| slices.MaxFunc | 0 | S | interface { ~[]E } | -| slices.MaxFunc | 1 | E | interface { } | -| slices.Min | 0 | S | interface { ~[]E } | -| slices.Min | 1 | E | Ordered | -| slices.MinFunc | 0 | S | interface { ~[]E } | -| slices.MinFunc | 1 | E | interface { } | -| slices.Repeat | 0 | S | interface { ~[]E } | -| slices.Repeat | 1 | E | interface { } | -| slices.Replace | 0 | S | interface { ~[]E } | -| slices.Replace | 1 | E | interface { } | -| slices.Reverse | 0 | S | interface { ~[]E } | -| slices.Reverse | 1 | E | interface { } | -| slices.Sort | 0 | S | interface { ~[]E } | -| slices.Sort | 1 | E | Ordered | -| slices.SortFunc | 0 | S | interface { ~[]E } | -| slices.SortFunc | 1 | E | interface { } | -| slices.SortStableFunc | 0 | S | interface { ~[]E } | -| slices.SortStableFunc | 1 | E | interface { } | -| slices.Sorted | 0 | E | Ordered | -| slices.SortedFunc | 0 | E | interface { } | -| slices.SortedStableFunc | 0 | E | interface { } | -| slices.Values | 0 | Slice | interface { ~[]E } | -| slices.Values | 1 | E | interface { } | -| slices.breakPatternsCmpFunc | 0 | E | interface { } | -| slices.breakPatternsOrdered | 0 | E | Ordered | -| slices.choosePivotCmpFunc | 0 | E | interface { } | -| slices.choosePivotOrdered | 0 | E | Ordered | -| slices.heapSortCmpFunc | 0 | E | interface { } | -| slices.heapSortOrdered | 0 | E | Ordered | -| slices.insertionSortCmpFunc | 0 | E | interface { } | -| slices.insertionSortOrdered | 0 | E | Ordered | -| slices.isNaN | 0 | T | Ordered | -| slices.medianAdjacentCmpFunc | 0 | E | interface { } | -| slices.medianAdjacentOrdered | 0 | E | Ordered | -| slices.medianCmpFunc | 0 | E | interface { } | -| slices.medianOrdered | 0 | E | Ordered | -| slices.order2CmpFunc | 0 | E | interface { } | -| slices.order2Ordered | 0 | E | Ordered | -| slices.overlaps | 0 | E | interface { } | -| slices.partialInsertionSortCmpFunc | 0 | E | interface { } | -| slices.partialInsertionSortOrdered | 0 | E | Ordered | -| slices.partitionCmpFunc | 0 | E | interface { } | -| slices.partitionEqualCmpFunc | 0 | E | interface { } | -| slices.partitionEqualOrdered | 0 | E | Ordered | -| slices.partitionOrdered | 0 | E | Ordered | -| slices.pdqsortCmpFunc | 0 | E | interface { } | -| slices.pdqsortOrdered | 0 | E | Ordered | -| slices.reverseRangeCmpFunc | 0 | E | interface { } | -| slices.reverseRangeOrdered | 0 | E | Ordered | -| slices.rotateCmpFunc | 0 | E | interface { } | -| slices.rotateLeft | 0 | E | interface { } | -| slices.rotateOrdered | 0 | E | Ordered | -| slices.rotateRight | 0 | E | interface { } | -| slices.siftDownCmpFunc | 0 | E | interface { } | -| slices.siftDownOrdered | 0 | E | Ordered | -| slices.stableCmpFunc | 0 | E | interface { } | -| slices.stableOrdered | 0 | E | Ordered | -| slices.startIdx | 0 | E | interface { } | -| slices.swapRangeCmpFunc | 0 | E | interface { } | -| slices.swapRangeOrdered | 0 | E | Ordered | -| slices.symMergeCmpFunc | 0 | E | interface { } | -| slices.symMergeOrdered | 0 | E | Ordered | -| strconv.bsearch | 0 | S | interface { ~[]E } | -| strconv.bsearch | 1 | E | interface { ~uint16 \| ~uint32 } | -| sync.OnceValue | 0 | T | interface { } | -| sync.OnceValues | 0 | T1 | interface { } | -| sync.OnceValues | 1 | T2 | interface { } | -| sync/atomic.Pointer | 0 | T | interface { } | -| sync/atomic.Pointer.CompareAndSwap | 0 | T | interface { } | -| sync/atomic.Pointer.Load | 0 | T | interface { } | -| sync/atomic.Pointer.Store | 0 | T | interface { } | -| sync/atomic.Pointer.Swap | 0 | T | interface { } | -| time.atoi | 0 | bytes | interface { []uint8 \| string } | -| time.isDigit | 0 | bytes | interface { []uint8 \| string } | -| time.leadingInt | 0 | bytes | interface { []uint8 \| string } | -| time.parseNanoseconds | 0 | bytes | interface { []uint8 \| string } | -| time.parseRFC3339 | 0 | bytes | interface { []uint8 \| string } | diff --git a/go/ql/test/library-tests/semmle/go/Function/TypeParamType.ql b/go/ql/test/library-tests/semmle/go/Function/TypeParamType.ql index 202a437d6a0b..02dec23d2a86 100644 --- a/go/ql/test/library-tests/semmle/go/Function/TypeParamType.ql +++ b/go/ql/test/library-tests/semmle/go/Function/TypeParamType.ql @@ -6,5 +6,9 @@ query predicate numberOfTypeParameters(TypeParamParentEntity parent, int n) { } from TypeParamType tpt, TypeParamParentEntity ty -where ty = tpt.getParent() +where + ty = tpt.getParent() and + // Note that we cannot use the location of `tpt` itself as we currently fail + // to extract an object for type parameters for methods on generic structs. + exists(ty.getLocation()) select ty.getQualifiedName(), tpt.getIndex(), tpt.getParamName(), tpt.getConstraint().pp()