From 998b73a2e99ff8340663236531963377815f5374 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 21 Apr 2014 11:20:54 -0700 Subject: [PATCH] go.tools/go/types: result of make and new builtins are not addressable LGTM=gri R=gri CC=golang-codereviews https://golang.org/cl/89390045 --- go/types/builtins.go | 4 ++-- go/types/testdata/builtins.src | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/go/types/builtins.go b/go/types/builtins.go index ebe8302498b..7fe8353ceda 100644 --- a/go/types/builtins.go +++ b/go/types/builtins.go @@ -397,7 +397,7 @@ func (check *checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b check.invalidArg(call.Args[1].Pos(), "length and capacity swapped") // safe to continue } - x.mode = variable + x.mode = value x.typ = T if check.Types != nil { params := [...]Type{T, Typ[Int], Typ[Int]} @@ -412,7 +412,7 @@ func (check *checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b return } - x.mode = variable + x.mode = value x.typ = &Pointer{base: T} if check.Types != nil { check.recordBuiltinType(call.Fun, makeSig(x.typ, T)) diff --git a/go/types/testdata/builtins.src b/go/types/testdata/builtins.src index 3cabd8ae3ed..9d39d40949d 100644 --- a/go/types/testdata/builtins.src +++ b/go/types/testdata/builtins.src @@ -436,6 +436,7 @@ func make1() { _ = make([]int, 10 /* ERROR length and capacity swapped */ , 9) _ = make([]int, 1 /* ERROR overflows */ <<100, 12345) _ = make([]int, m /* ERROR must be integer */ ) + _ = &make /* ERROR cannot take address */ ([]int, 0) // maps _ = make /* ERROR arguments */ (map[int]string, 10, 20) @@ -446,6 +447,7 @@ func make1() { _ = make(map[int]float32, int64(n)) _ = make(map[string]bool, 10.0) _ = make(map[string]bool, 10.0<