diff options
| author | Robert Griesemer <gri@golang.org> | 2020-02-23 13:08:29 -0800 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2020-02-24 02:36:05 +0000 |
| commit | 151ccd4bdb06d77e89f00b8172b70cfb2f49ca2b (patch) | |
| tree | 9568e3cb39568d5922be9539961e9969ae4954a1 /src | |
| parent | ec4c9db21015cf53661661b95b19110ed71dd49d (diff) | |
| download | go-151ccd4bdb06d77e89f00b8172b70cfb2f49ca2b.tar.xz | |
go/types: report correct number of arguments for make() built-in calls
Also: Added test cases for (separate) issue #37393.
To be enabled when that issue is fixed.
Fixes #37349.
Updates #37393.
Change-Id: Ib78cb0614c0b396241af06a3aa5d37d8045c2f2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/220584
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/go/types/builtins.go | 2 | ||||
| -rw-r--r-- | src/go/types/builtins_test.go | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/go/types/builtins.go b/src/go/types/builtins.go index 3756303dfb..cc50f677c7 100644 --- a/src/go/types/builtins.go +++ b/src/go/types/builtins.go @@ -455,7 +455,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b x.typ = T if check.Types != nil { params := [...]Type{T, Typ[Int], Typ[Int]} - check.recordBuiltinType(call.Fun, makeSig(x.typ, params[:1+len(sizes)]...)) + check.recordBuiltinType(call.Fun, makeSig(x.typ, params[:nargs]...)) } case _New: diff --git a/src/go/types/builtins_test.go b/src/go/types/builtins_test.go index 9835a48267..ac0145ea87 100644 --- a/src/go/types/builtins_test.go +++ b/src/go/types/builtins_test.go @@ -71,6 +71,23 @@ var builtinCalls = []struct { {"make", `_ = make([]int, 10)`, `func([]int, int) []int`}, {"make", `type T []byte; _ = make(T, 10, 20)`, `func(p.T, int, int) p.T`}, + // issue #37349 + {"make", ` _ = make([]int, 0 )`, `func([]int, int) []int`}, + {"make", `var l int; _ = make([]int, l )`, `func([]int, int) []int`}, + {"make", ` _ = make([]int, 0, 0)`, `func([]int, int, int) []int`}, + {"make", `var l int; _ = make([]int, l, 0)`, `func([]int, int, int) []int`}, + {"make", `var c int; _ = make([]int, 0, c)`, `func([]int, int, int) []int`}, + {"make", `var l, c int; _ = make([]int, l, c)`, `func([]int, int, int) []int`}, + + // TODO(gri) enable once the issue is fixed + // issue #37393 + // {"make", ` _ = make([]int , 0 )`, `func([]int, int) []int`}, + // {"make", `var l byte ; _ = make([]int8 , l )`, `func([]int8, byte) []int8`}, + // {"make", ` _ = make([]int16 , 0, 0)`, `func([]int16, int, int) []int16`}, + // {"make", `var l int16; _ = make([]string , l, 0)`, `func([]string, int16, int) []string`}, + // {"make", `var c int32; _ = make([]float64 , 0, c)`, `func([]float64, int, int32) []float64`}, + // {"make", `var l, c uint ; _ = make([]complex128, l, c)`, `func([]complex128, uint, uint) []complex128`}, + {"new", `_ = new(int)`, `func(int) *int`}, {"new", `type T struct{}; _ = new(T)`, `func(p.T) *p.T`}, |
