mirror of
https://github.com/golang/go
synced 2024-07-20 17:48:31 +00:00
cmd/gc: reject builtin function calls in len(fixed array) constants
Fixes #7385. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://golang.org/cl/84010044
This commit is contained in:
parent
a26c01ad44
commit
f3ecb298ad
|
@ -1629,10 +1629,25 @@ hascallchan(Node *n)
|
|||
if(n == N)
|
||||
return 0;
|
||||
switch(n->op) {
|
||||
case OAPPEND:
|
||||
case OCALL:
|
||||
case OCALLFUNC:
|
||||
case OCALLMETH:
|
||||
case OCALLINTER:
|
||||
case OCALLMETH:
|
||||
case OCAP:
|
||||
case OCLOSE:
|
||||
case OCOMPLEX:
|
||||
case OCOPY:
|
||||
case ODELETE:
|
||||
case OIMAG:
|
||||
case OLEN:
|
||||
case OMAKE:
|
||||
case ONEW:
|
||||
case OPANIC:
|
||||
case OPRINT:
|
||||
case OPRINTN:
|
||||
case OREAL:
|
||||
case ORECOVER:
|
||||
case ORECV:
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ var s [][30]int
|
|||
|
||||
func f() *[40]int
|
||||
var c chan *[50]int
|
||||
var z complex128
|
||||
|
||||
const (
|
||||
n1 = len(b.a)
|
||||
|
@ -29,5 +30,8 @@ const (
|
|||
|
||||
n6 = cap(f()) // ERROR "is not a constant|is not constant"
|
||||
n7 = cap(<-c) // ERROR "is not a constant|is not constant"
|
||||
n8 = real(z) // ERROR "is not a constant|is not constant"
|
||||
n9 = len([4]float64{real(z)}) // ERROR "is not a constant|is not constant"
|
||||
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue