From 34f8f2457e185872175e84c9661852bf96c409c9 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 17 Jul 2023 13:18:17 +0200 Subject: [PATCH] chore: min go1.19 --- analyzer/analyzer.go | 3 +- analyzer/analyzer_test.go | 5 +- cmd/gorules/main.go | 8 ++-- go.mod | 2 +- go.sum | 30 ------------ ruleguard/engine.go | 3 +- ruleguard/ir/gen_filter_op.go | 4 +- ruleguard/ir_loader.go | 4 +- ruleguard/quasigo/eval_test.go | 3 +- ruleguard/quasigo/gen_opcodes.go | 4 +- ruleguard/runner.go | 4 +- ruleguard/testdata/bench_target1.go | 13 +++--- ruleguard/typematch/typematch_test.go | 66 +++++++++++++-------------- 13 files changed, 56 insertions(+), 93 deletions(-) diff --git a/analyzer/analyzer.go b/analyzer/analyzer.go index 1a3a2a2d..191981d2 100644 --- a/analyzer/analyzer.go +++ b/analyzer/analyzer.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "go/token" - "io/ioutil" "os" "path/filepath" "strings" @@ -232,7 +231,7 @@ func newEngine() (*ruleguard.Engine, error) { filenames := strings.Split(flagRules, ",") for _, filename := range filenames { filename = strings.TrimSpace(filename) - data, err := ioutil.ReadFile(filename) + data, err := os.ReadFile(filename) if err != nil { return nil, fmt.Errorf("read rules file: %v", err) } diff --git a/analyzer/analyzer_test.go b/analyzer/analyzer_test.go index e218a341..69c66b5f 100644 --- a/analyzer/analyzer_test.go +++ b/analyzer/analyzer_test.go @@ -5,7 +5,6 @@ import ( "fmt" "go/token" "io/fs" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -180,7 +179,7 @@ var rulesFile = %s } t.Run(test.name, func(t *testing.T) { rulesFilename := filepath.Join(wd, "testdata", "src", test.name, "rules.go") - data, err := ioutil.ReadFile(rulesFilename) + data, err := os.ReadFile(rulesFilename) if err != nil { t.Fatalf("%s: %v", test.name, err) } @@ -205,7 +204,7 @@ var rulesFile = %s } var irfileBuf bytes.Buffer irprint.File(&irfileBuf, irfile) - mainFile, err := ioutil.TempFile("", "ruleguard-test*.go") + mainFile, err := os.CreateTemp("", "ruleguard-test*.go") if err != nil { t.Fatal(err) } diff --git a/cmd/gorules/main.go b/cmd/gorules/main.go index 689b7df5..1690c3df 100644 --- a/cmd/gorules/main.go +++ b/cmd/gorules/main.go @@ -2,8 +2,6 @@ package main import ( "bytes" - "os" - "encoding/json" "flag" "fmt" @@ -12,8 +10,8 @@ import ( "go/parser" "go/token" "go/types" - "io/ioutil" "log" + "os" "path/filepath" "strings" @@ -86,7 +84,7 @@ func docCommand(args []string) error { filenames := strings.Split(*flagRules, ",") for _, filename := range filenames { filename = strings.TrimSpace(filename) - data, err := ioutil.ReadFile(filename) + data, err := os.ReadFile(filename) if err != nil { return fmt.Errorf("read rules file: %v", err) } @@ -164,7 +162,7 @@ func precompileCommand(args []string) error { fset := token.NewFileSet() filename := strings.TrimSpace(*flagRules) - fileData, err := ioutil.ReadFile(filename) + fileData, err := os.ReadFile(filename) if err != nil { return fmt.Errorf("read %s: %v", filename, err) } diff --git a/go.mod b/go.mod index 67bfcaf8..a4e32408 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/quasilyte/go-ruleguard -go 1.17 +go 1.19 require ( github.com/go-toolsmith/astcopy v1.0.2 diff --git a/go.sum b/go.sum index bf070181..6d0fd65a 100644 --- a/go.sum +++ b/go.sum @@ -22,65 +22,35 @@ github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4l github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 h1:jWGQJV4niP+CCmFW9ekjA9Zx8vYORzOUH2/Nl5WPuLQ= golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200812195022-5ae4c3c160a0/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20201230224404-63754364767c/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8= golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/ruleguard/engine.go b/ruleguard/engine.go index 88feef92..e4cf954f 100644 --- a/ruleguard/engine.go +++ b/ruleguard/engine.go @@ -8,7 +8,6 @@ import ( "go/token" "go/types" "io" - "io/ioutil" "os" "sort" "strings" @@ -48,7 +47,7 @@ func (e *engine) LoadedGroups() []GoRuleGroup { } func (e *engine) Load(ctx *LoadContext, buildContext *build.Context, filename string, r io.Reader) error { - data, err := ioutil.ReadAll(r) + data, err := io.ReadAll(r) if err != nil { return err } diff --git a/ruleguard/ir/gen_filter_op.go b/ruleguard/ir/gen_filter_op.go index aecb975d..b1c81949 100644 --- a/ruleguard/ir/gen_filter_op.go +++ b/ruleguard/ir/gen_filter_op.go @@ -7,7 +7,7 @@ import ( "bytes" "fmt" "go/format" - "io/ioutil" + "os" "strings" ) @@ -142,7 +142,7 @@ func main() { panic(err) } - if err := ioutil.WriteFile("filter_op.gen.go", pretty, 0644); err != nil { + if err := os.WriteFile("filter_op.gen.go", pretty, 0644); err != nil { panic(err) } } diff --git a/ruleguard/ir_loader.go b/ruleguard/ir_loader.go index d7166891..dcb2fd2a 100644 --- a/ruleguard/ir_loader.go +++ b/ruleguard/ir_loader.go @@ -8,7 +8,7 @@ import ( "go/parser" "go/token" "go/types" - "io/ioutil" + "os" "regexp" "github.com/quasilyte/gogrep" @@ -144,7 +144,7 @@ func (l *irLoader) loadBundle(bundle ir.BundleImport) error { } func (l *irLoader) loadExternFile(prefix, pkgPath, filename string) (*goRuleSet, error) { - src, err := ioutil.ReadFile(filename) + src, err := os.ReadFile(filename) if err != nil { return nil, err } diff --git a/ruleguard/quasigo/eval_test.go b/ruleguard/quasigo/eval_test.go index 53bdbdc5..924c588e 100644 --- a/ruleguard/quasigo/eval_test.go +++ b/ruleguard/quasigo/eval_test.go @@ -4,7 +4,6 @@ import ( "bytes" "errors" "fmt" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -241,7 +240,7 @@ func TestEval(t *testing.T) { } func TestEvalFile(t *testing.T) { - files, err := ioutil.ReadDir("testdata") + files, err := os.ReadDir("testdata") if err != nil { t.Fatal(err) } diff --git a/ruleguard/quasigo/gen_opcodes.go b/ruleguard/quasigo/gen_opcodes.go index c8d51203..80386df2 100644 --- a/ruleguard/quasigo/gen_opcodes.go +++ b/ruleguard/quasigo/gen_opcodes.go @@ -7,8 +7,8 @@ import ( "bytes" "fmt" "go/format" - "io/ioutil" "log" + "os" "strings" "text/template" ) @@ -186,7 +186,7 @@ func writeFile(filename string, data []byte) { if err != nil { log.Panicf("gofmt: %v", err) } - if err := ioutil.WriteFile(filename, pretty, 0666); err != nil { + if err := os.WriteFile(filename, pretty, 0666); err != nil { log.Panicf("write %s: %v", filename, err) } } diff --git a/ruleguard/runner.go b/ruleguard/runner.go index c76b6db3..fdc95ab5 100644 --- a/ruleguard/runner.go +++ b/ruleguard/runner.go @@ -8,7 +8,7 @@ import ( "go/build" "go/printer" "go/token" - "io/ioutil" + "os" "path/filepath" "reflect" "sort" @@ -166,7 +166,7 @@ func (rr *rulesRunner) fileBytes() []byte { } // TODO(quasilyte): re-use src slice? - src, err := ioutil.ReadFile(rr.filename) + src, err := os.ReadFile(rr.filename) if err != nil || src == nil { // Assign a zero-length slice so rr.src // is never nil during the second fileBytes call. diff --git a/ruleguard/testdata/bench_target1.go b/ruleguard/testdata/bench_target1.go index 56ba0dfa..5ce78148 100644 --- a/ruleguard/testdata/bench_target1.go +++ b/ruleguard/testdata/bench_target1.go @@ -18,12 +18,11 @@ package main // Import declaration declares library packages referenced in this file. import ( - "fmt" // A package in the Go standard library. - "io/ioutil" // Implements some I/O utility functions. - m "math" // Math library with local alias m. - "net/http" // Yes, a web server! - "os" // OS functions like working with the file system - "strconv" // String conversions. + "fmt" // A package in the Go standard library. + m "math" // Math library with local alias m. + "net/http" // Yes, a web server! + "os" // OS functions like working with the file system + "strconv" // String conversions. ) // A function definition. Main is special. It is the entry point for the @@ -416,6 +415,6 @@ func requestServer() { resp, err := http.Get("http://localhost:8080") fmt.Println(err) defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := os.ReadAll(resp.Body) fmt.Printf("\nWebserver said: %s", string(body)) } diff --git a/ruleguard/typematch/typematch_test.go b/ruleguard/typematch/typematch_test.go index 3221c4f3..bb22a51e 100644 --- a/ruleguard/typematch/typematch_test.go +++ b/ruleguard/typematch/typematch_test.go @@ -17,7 +17,7 @@ var ( stringerIface = types.NewInterfaceType([]*types.Func{ types.NewFunc(token.NoPos, nil, "String", - types.NewSignature(nil, types.NewTuple(), types.NewTuple(types.NewVar(token.NoPos, nil, "result", typeString)), false)), + types.NewSignatureType(nil, nil, nil, types.NewTuple(), types.NewTuple(types.NewVar(token.NoPos, nil, "result", typeString)), false)), }, nil) intVar = types.NewVar(token.NoPos, nil, "_", typeInt) @@ -95,30 +95,30 @@ func TestIdentical(t *testing.T) { {`unsafe.Pointer`, typeUnsafePtr}, {`[]unsafe.Pointer`, types.NewSlice(typeUnsafePtr)}, - {`func()`, types.NewSignature(nil, nil, nil, false)}, - {`func(int)`, types.NewSignature(nil, types.NewTuple(intVar), nil, false)}, - {`func(int, string)`, types.NewSignature(nil, types.NewTuple(intVar, stringVar), nil, false)}, - {`func() int`, types.NewSignature(nil, nil, types.NewTuple(intVar), false)}, - {`func(string) int`, types.NewSignature(nil, types.NewTuple(stringVar), types.NewTuple(intVar), false)}, - {`func(int) int`, types.NewSignature(nil, types.NewTuple(intVar), types.NewTuple(intVar), false)}, - {`func() (string, int)`, types.NewSignature(nil, nil, types.NewTuple(stringVar, intVar), false)}, + {`func()`, types.NewSignatureType(nil, nil, nil, nil, nil, false)}, + {`func(int)`, types.NewSignatureType(nil, nil, nil, types.NewTuple(intVar), nil, false)}, + {`func(int, string)`, types.NewSignatureType(nil, nil, nil, types.NewTuple(intVar, stringVar), nil, false)}, + {`func() int`, types.NewSignatureType(nil, nil, nil, nil, types.NewTuple(intVar), false)}, + {`func(string) int`, types.NewSignatureType(nil, nil, nil, types.NewTuple(stringVar), types.NewTuple(intVar), false)}, + {`func(int) int`, types.NewSignatureType(nil, nil, nil, types.NewTuple(intVar), types.NewTuple(intVar), false)}, + {`func() (string, int)`, types.NewSignatureType(nil, nil, nil, nil, types.NewTuple(stringVar, intVar), false)}, - {`func($_)`, types.NewSignature(nil, types.NewTuple(intVar), nil, false)}, - {`func($_)`, types.NewSignature(nil, types.NewTuple(stringVar), nil, false)}, - {`func($_) int`, types.NewSignature(nil, types.NewTuple(intVar), types.NewTuple(intVar), false)}, - {`func($_) int`, types.NewSignature(nil, types.NewTuple(stringVar), types.NewTuple(intVar), false)}, + {`func($_)`, types.NewSignatureType(nil, nil, nil, types.NewTuple(intVar), nil, false)}, + {`func($_)`, types.NewSignatureType(nil, nil, nil, types.NewTuple(stringVar), nil, false)}, + {`func($_) int`, types.NewSignatureType(nil, nil, nil, types.NewTuple(intVar), types.NewTuple(intVar), false)}, + {`func($_) int`, types.NewSignatureType(nil, nil, nil, types.NewTuple(stringVar), types.NewTuple(intVar), false)}, - {`func($*_) int`, types.NewSignature(nil, types.NewTuple(stringVar), types.NewTuple(intVar), false)}, - {`func($*_) int`, types.NewSignature(nil, nil, types.NewTuple(intVar), false)}, - {`func($*_) $_`, types.NewSignature(nil, nil, types.NewTuple(intVar), false)}, + {`func($*_) int`, types.NewSignatureType(nil, nil, nil, types.NewTuple(stringVar), types.NewTuple(intVar), false)}, + {`func($*_) int`, types.NewSignatureType(nil, nil, nil, nil, types.NewTuple(intVar), false)}, + {`func($*_) $_`, types.NewSignatureType(nil, nil, nil, nil, types.NewTuple(intVar), false)}, - {`func($t, $t)`, types.NewSignature(nil, types.NewTuple(stringVar, stringVar), nil, false)}, - {`func($t, $t)`, types.NewSignature(nil, types.NewTuple(intVar, intVar), nil, false)}, + {`func($t, $t)`, types.NewSignatureType(nil, nil, nil, types.NewTuple(stringVar, stringVar), nil, false)}, + {`func($t, $t)`, types.NewSignatureType(nil, nil, nil, types.NewTuple(intVar, intVar), nil, false)}, // Any func. - {`func($*_) $*_`, types.NewSignature(nil, nil, nil, false)}, - {`func($*_) $*_`, types.NewSignature(nil, types.NewTuple(stringVar, stringVar), nil, false)}, - {`func($*_) $*_`, types.NewSignature(nil, types.NewTuple(stringVar), types.NewTuple(intVar), false)}, + {`func($*_) $*_`, types.NewSignatureType(nil, nil, nil, nil, nil, false)}, + {`func($*_) $*_`, types.NewSignatureType(nil, nil, nil, types.NewTuple(stringVar, stringVar), nil, false)}, + {`func($*_) $*_`, types.NewSignatureType(nil, nil, nil, types.NewTuple(stringVar), types.NewTuple(intVar), false)}, {`struct{}`, typeEstruct}, {`struct{int}`, types.NewStruct([]*types.Var{intVar}, nil)}, @@ -203,21 +203,21 @@ func TestIdenticalNegative(t *testing.T) { {`syntax.Regexp`, namedType2("regexp2/syntax", "Regexp")}, {`syntax.Regexp`, namedType2("regexp2/syntax", "Blah")}, - {`func(int)`, types.NewSignature(nil, nil, nil, false)}, - {`func() int`, types.NewSignature(nil, types.NewTuple(intVar), nil, false)}, - {`func(int, int)`, types.NewSignature(nil, types.NewTuple(intVar, stringVar), nil, false)}, - {`func() string`, types.NewSignature(nil, nil, types.NewTuple(intVar), false)}, - {`func(string, string) int`, types.NewSignature(nil, types.NewTuple(stringVar), types.NewTuple(intVar), false)}, - {`func(string) string`, types.NewSignature(nil, nil, types.NewTuple(stringVar, intVar), false)}, + {`func(int)`, types.NewSignatureType(nil, nil, nil, nil, nil, false)}, + {`func() int`, types.NewSignatureType(nil, nil, nil, types.NewTuple(intVar), nil, false)}, + {`func(int, int)`, types.NewSignatureType(nil, nil, nil, types.NewTuple(intVar, stringVar), nil, false)}, + {`func() string`, types.NewSignatureType(nil, nil, nil, nil, types.NewTuple(intVar), false)}, + {`func(string, string) int`, types.NewSignatureType(nil, nil, nil, types.NewTuple(stringVar), types.NewTuple(intVar), false)}, + {`func(string) string`, types.NewSignatureType(nil, nil, nil, nil, types.NewTuple(stringVar, intVar), false)}, - {`func($_) int`, types.NewSignature(nil, types.NewTuple(intVar), types.NewTuple(stringVar), false)}, + {`func($_) int`, types.NewSignatureType(nil, nil, nil, types.NewTuple(intVar), types.NewTuple(stringVar), false)}, - {`func($t, $t)`, types.NewSignature(nil, types.NewTuple(intVar, stringVar), nil, false)}, - {`func($t, $t)`, types.NewSignature(nil, types.NewTuple(stringVar, intVar), nil, false)}, + {`func($t, $t)`, types.NewSignatureType(nil, nil, nil, types.NewTuple(intVar, stringVar), nil, false)}, + {`func($t, $t)`, types.NewSignatureType(nil, nil, nil, types.NewTuple(stringVar, intVar), nil, false)}, - {`func($*_) int`, types.NewSignature(nil, types.NewTuple(stringVar), types.NewTuple(stringVar), false)}, - {`func($*_) int`, types.NewSignature(nil, nil, nil, false)}, - {`func($*_) $_`, types.NewSignature(nil, nil, nil, false)}, + {`func($*_) int`, types.NewSignatureType(nil, nil, nil, types.NewTuple(stringVar), types.NewTuple(stringVar), false)}, + {`func($*_) int`, types.NewSignatureType(nil, nil, nil, nil, nil, false)}, + {`func($*_) $_`, types.NewSignatureType(nil, nil, nil, nil, nil, false)}, // Any func negative. {`func($*_) $*_`, typeInt}, @@ -256,7 +256,7 @@ func TestIdenticalNegative(t *testing.T) { // TODO: this should fail as $* is named. // We don't support named $* now, but they should be supported. - //{`struct{$*x; int; $*x}`, structType(stringVar, intVar, intVar)}, + // {`struct{$*x; int; $*x}`, structType(stringVar, intVar, intVar)}, } state := NewMatcherState()