Skip to content

Commit b8ea840

Browse files
committed
Add type param decls to PrintAST tests
1 parent 5efb88e commit b8ea840

File tree

7 files changed

+152
-3
lines changed

7 files changed

+152
-3
lines changed

go/ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
other.go:
2+
# 8| [TypeParamDecl] type parameter declaration
3+
# 8| 0: [Ident, TypeName] int
4+
# 8| Type = int
5+
# 8| 1: [Ident, TypeName] U
6+
# 8| Type = U
7+
# 17| [TypeParamDecl] type parameter declaration
8+
# 17| 0: [TypeSetLiteralExpr] type set literal
9+
# 17| Type = ~string
10+
# 17| 0: [Ident, TypeName] string
11+
# 17| Type = string
12+
# 17| 1: [Ident, TypeName] T
13+
# 17| Type = T
114
go.mod:
215
# 0| [GoModFile] go.mod
316
# 1| 0: [GoModModuleLine] go.mod module line
@@ -648,3 +661,25 @@ other.go:
648661
# 15| 2: [IntLit] 0
649662
# 15| Type = int
650663
# 15| Value = [IntLit] 0
664+
# 17| 6: [TypeDecl] type declaration
665+
# 17| 0: [TypeSpec] type declaration specifier
666+
# 17| 0: [Ident, TypeName] myType
667+
# 17| Type = myType
668+
# 17| 1: [ArrayTypeExpr] array type
669+
# 17| Type = []T
670+
# 17| 0: [Ident, TypeName] T
671+
# 17| Type = T
672+
# 19| 7: [MethodDecl] function declaration
673+
# 19| 0: [FunctionName, Ident] f
674+
# 19| Type = func()
675+
# 19| 1: [FuncTypeExpr] function type
676+
# 19| 2: [ReceiverDecl] receiver declaration
677+
# 19| 0: [GenericTypeInstantiationExpr] generic type instantiation expression
678+
# 19| Type = myType
679+
# 19| 0: [Ident, TypeName] myType
680+
# 19| Type = myType
681+
# 19| 1: [Ident, TypeName] U
682+
# 19| Type = U
683+
# 19| 1: [Ident, VariableName] m
684+
# 19| Type = myType
685+
# 19| 3: [BlockStmt] block statement

go/ql/test/library-tests/semmle/go/PrintAst/PrintAstExcludeComments.expected

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
other.go:
2+
# 8| [TypeParamDecl] type parameter declaration
3+
# 8| 0: [Ident, TypeName] int
4+
# 8| Type = int
5+
# 8| 1: [Ident, TypeName] U
6+
# 8| Type = U
7+
# 17| [TypeParamDecl] type parameter declaration
8+
# 17| 0: [TypeSetLiteralExpr] type set literal
9+
# 17| Type = ~string
10+
# 17| 0: [Ident, TypeName] string
11+
# 17| Type = string
12+
# 17| 1: [Ident, TypeName] T
13+
# 17| Type = T
114
go.mod:
215
# 0| [GoModFile] go.mod
316
# 1| 0: [GoModModuleLine] go.mod module line
@@ -628,3 +641,25 @@ other.go:
628641
# 15| 2: [IntLit] 0
629642
# 15| Type = int
630643
# 15| Value = [IntLit] 0
644+
# 17| 6: [TypeDecl] type declaration
645+
# 17| 0: [TypeSpec] type declaration specifier
646+
# 17| 0: [Ident, TypeName] myType
647+
# 17| Type = myType
648+
# 17| 1: [ArrayTypeExpr] array type
649+
# 17| Type = []T
650+
# 17| 0: [Ident, TypeName] T
651+
# 17| Type = T
652+
# 19| 7: [MethodDecl] function declaration
653+
# 19| 0: [FunctionName, Ident] f
654+
# 19| Type = func()
655+
# 19| 1: [FuncTypeExpr] function type
656+
# 19| 2: [ReceiverDecl] receiver declaration
657+
# 19| 0: [GenericTypeInstantiationExpr] generic type instantiation expression
658+
# 19| Type = myType
659+
# 19| 0: [Ident, TypeName] myType
660+
# 19| Type = myType
661+
# 19| 1: [Ident, TypeName] U
662+
# 19| Type = U
663+
# 19| 1: [Ident, VariableName] m
664+
# 19| Type = myType
665+
# 19| 3: [BlockStmt] block statement

go/ql/test/library-tests/semmle/go/PrintAst/PrintAstNestedFunction.expected

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
other.go:
2+
# 8| [TypeParamDecl] type parameter declaration
3+
# 8| 0: [Ident, TypeName] int
4+
# 8| Type = int
5+
# 8| 1: [Ident, TypeName] U
6+
# 8| Type = U
7+
# 17| [TypeParamDecl] type parameter declaration
8+
# 17| 0: [TypeSetLiteralExpr] type set literal
9+
# 17| Type = ~string
10+
# 17| 0: [Ident, TypeName] string
11+
# 17| Type = string
12+
# 17| 1: [Ident, TypeName] T
13+
# 17| Type = T
114
go.mod:
215
# 0| [GoModFile] go.mod
316
# 1| 0: [GoModModuleLine] go.mod module line
@@ -65,3 +78,11 @@ other.go:
6578
# 15| 2: [IntLit] 0
6679
# 15| Type = int
6780
# 15| Value = [IntLit] 0
81+
# 17| 3: [TypeDecl] type declaration
82+
# 17| 0: [TypeSpec] type declaration specifier
83+
# 17| 0: [Ident, TypeName] myType
84+
# 17| Type = myType
85+
# 17| 1: [ArrayTypeExpr] array type
86+
# 17| Type = []T
87+
# 17| 0: [Ident, TypeName] T
88+
# 17| Type = T

go/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFile.expected

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
other.go:
2+
# 8| [TypeParamDecl] type parameter declaration
3+
# 8| 0: [Ident, TypeName] int
4+
# 8| Type = int
5+
# 8| 1: [Ident, TypeName] U
6+
# 8| Type = U
7+
# 17| [TypeParamDecl] type parameter declaration
8+
# 17| 0: [TypeSetLiteralExpr] type set literal
9+
# 17| Type = ~string
10+
# 17| 0: [Ident, TypeName] string
11+
# 17| Type = string
12+
# 17| 1: [Ident, TypeName] T
13+
# 17| Type = T
214
# 0| [GoFile] other.go
315
# 1| package: [Ident] main
416
# 3| 1: [FuncDecl] function declaration
@@ -50,3 +62,25 @@ other.go:
5062
# 15| 2: [IntLit] 0
5163
# 15| Type = int
5264
# 15| Value = [IntLit] 0
65+
# 17| 6: [TypeDecl] type declaration
66+
# 17| 0: [TypeSpec] type declaration specifier
67+
# 17| 0: [Ident, TypeName] myType
68+
# 17| Type = myType
69+
# 17| 1: [ArrayTypeExpr] array type
70+
# 17| Type = []T
71+
# 17| 0: [Ident, TypeName] T
72+
# 17| Type = T
73+
# 19| 7: [MethodDecl] function declaration
74+
# 19| 0: [FunctionName, Ident] f
75+
# 19| Type = func()
76+
# 19| 1: [FuncTypeExpr] function type
77+
# 19| 2: [ReceiverDecl] receiver declaration
78+
# 19| 0: [GenericTypeInstantiationExpr] generic type instantiation expression
79+
# 19| Type = myType
80+
# 19| 0: [Ident, TypeName] myType
81+
# 19| Type = myType
82+
# 19| 1: [Ident, TypeName] U
83+
# 19| Type = U
84+
# 19| 1: [Ident, VariableName] m
85+
# 19| Type = myType
86+
# 19| 3: [BlockStmt] block statement

go/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFunction.expected

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
other.go:
2+
# 8| [TypeParamDecl] type parameter declaration
3+
# 8| 0: [Ident, TypeName] int
4+
# 8| Type = int
5+
# 8| 1: [Ident, TypeName] U
6+
# 8| Type = U
7+
# 17| [TypeParamDecl] type parameter declaration
8+
# 17| 0: [TypeSetLiteralExpr] type set literal
9+
# 17| Type = ~string
10+
# 17| 0: [Ident, TypeName] string
11+
# 17| Type = string
12+
# 17| 1: [Ident, TypeName] T
13+
# 17| Type = T
114
go.mod:
215
# 0| [GoModFile] go.mod
316
# 1| 0: [GoModModuleLine] go.mod module line
@@ -45,3 +58,11 @@ other.go:
4558
# 15| 2: [IntLit] 0
4659
# 15| Type = int
4760
# 15| Value = [IntLit] 0
61+
# 17| 3: [TypeDecl] type declaration
62+
# 17| 0: [TypeSpec] type declaration specifier
63+
# 17| 0: [Ident, TypeName] myType
64+
# 17| Type = myType
65+
# 17| 1: [ArrayTypeExpr] array type
66+
# 17| Type = []T
67+
# 17| 0: [Ident, TypeName] T
68+
# 17| Type = T
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
module codeql-go-tests/printast
22

3-
go 1.14
4-
3+
go 1.18

go/ql/test/library-tests/semmle/go/PrintAst/other.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ func main() {}
55
func f() {}
66
func g() {}
77

8-
func hasNested() {
8+
func hasNested[U int]() {
99

1010
myNested := func() int { return 1 }
1111
myNested()
1212

1313
}
1414

1515
var x int = 0
16+
17+
type myType[T ~string] []T
18+
19+
func (m myType[U]) f() {}

0 commit comments

Comments
 (0)