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
This commit is contained in:
parent
379e0e7704
commit
998b73a2e9
|
@ -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")
|
check.invalidArg(call.Args[1].Pos(), "length and capacity swapped")
|
||||||
// safe to continue
|
// safe to continue
|
||||||
}
|
}
|
||||||
x.mode = variable
|
x.mode = value
|
||||||
x.typ = T
|
x.typ = T
|
||||||
if check.Types != nil {
|
if check.Types != nil {
|
||||||
params := [...]Type{T, Typ[Int], Typ[Int]}
|
params := [...]Type{T, Typ[Int], Typ[Int]}
|
||||||
|
@ -412,7 +412,7 @@ func (check *checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
x.mode = variable
|
x.mode = value
|
||||||
x.typ = &Pointer{base: T}
|
x.typ = &Pointer{base: T}
|
||||||
if check.Types != nil {
|
if check.Types != nil {
|
||||||
check.recordBuiltinType(call.Fun, makeSig(x.typ, T))
|
check.recordBuiltinType(call.Fun, makeSig(x.typ, T))
|
||||||
|
|
|
@ -436,6 +436,7 @@ func make1() {
|
||||||
_ = make([]int, 10 /* ERROR length and capacity swapped */ , 9)
|
_ = make([]int, 10 /* ERROR length and capacity swapped */ , 9)
|
||||||
_ = make([]int, 1 /* ERROR overflows */ <<100, 12345)
|
_ = make([]int, 1 /* ERROR overflows */ <<100, 12345)
|
||||||
_ = make([]int, m /* ERROR must be integer */ )
|
_ = make([]int, m /* ERROR must be integer */ )
|
||||||
|
_ = &make /* ERROR cannot take address */ ([]int, 0)
|
||||||
|
|
||||||
// maps
|
// maps
|
||||||
_ = make /* ERROR arguments */ (map[int]string, 10, 20)
|
_ = make /* ERROR arguments */ (map[int]string, 10, 20)
|
||||||
|
@ -446,6 +447,7 @@ func make1() {
|
||||||
_ = make(map[int]float32, int64(n))
|
_ = make(map[int]float32, int64(n))
|
||||||
_ = make(map[string]bool, 10.0)
|
_ = make(map[string]bool, 10.0)
|
||||||
_ = make(map[string]bool, 10.0<<s)
|
_ = make(map[string]bool, 10.0<<s)
|
||||||
|
_ = &make /* ERROR cannot take address */ (map[string]bool)
|
||||||
|
|
||||||
// channels
|
// channels
|
||||||
_ = make /* ERROR arguments */ (chan int, 10, 20)
|
_ = make /* ERROR arguments */ (chan int, 10, 20)
|
||||||
|
@ -456,6 +458,7 @@ func make1() {
|
||||||
_ = make(chan string, int64(n))
|
_ = make(chan string, int64(n))
|
||||||
_ = make(chan bool, 10.0)
|
_ = make(chan bool, 10.0)
|
||||||
_ = make(chan bool, 10.0<<s)
|
_ = make(chan bool, 10.0<<s)
|
||||||
|
_ = &make /* ERROR cannot take address */ (chan bool)
|
||||||
|
|
||||||
make /* ERROR not used */ ([]int, 10)
|
make /* ERROR not used */ ([]int, 10)
|
||||||
|
|
||||||
|
@ -479,6 +482,7 @@ func new1() {
|
||||||
q := new(*float64)
|
q := new(*float64)
|
||||||
_ = *p == **q
|
_ = *p == **q
|
||||||
new /* ERROR not used */ (int)
|
new /* ERROR not used */ (int)
|
||||||
|
_ = &new /* ERROR cannot take address */ (int)
|
||||||
|
|
||||||
_ = new(int... /* ERROR invalid use of \.\.\. */ )
|
_ = new(int... /* ERROR invalid use of \.\.\. */ )
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue