diff --git a/go/types/call.go b/go/types/call.go index a5895106..7bcf216d 100644 --- a/go/types/call.go +++ b/go/types/call.go @@ -45,9 +45,10 @@ func (check *checker) call(x *operand, e *ast.CallExpr) exprKind { x.mode = invalid } x.expr = e - // TODO(gri) Depending on the pending decision on the issue 7387, - // hasCallOrRecv may only need to be set if the result is not constant. - check.hasCallOrRecv = true + // a non-constant result implies a function call + if x.mode != invalid && x.mode != constant { + check.hasCallOrRecv = true + } return predeclaredFuncs[id].kind default: diff --git a/go/types/testdata/builtins.src b/go/types/testdata/builtins.src index 22ebbea2..3cabd8ae 100644 --- a/go/types/testdata/builtins.src +++ b/go/types/testdata/builtins.src @@ -121,13 +121,14 @@ func cap3() { _ = cap([4]int{x}) _ = cap /* ERROR not constant */ ([4]int{f()}) _ = cap /* ERROR not constant */ ([4]int{cap([]int{})}) - _ = cap /* ERROR not constant */ ([4]int{cap([4]int{})}) + _ = cap([4]int{cap([4]int{})}) ) var y float64 var z complex128 const ( _ = cap([4]float64{}) _ = cap([4]float64{y}) + _ = cap([4]float64{real(2i)}) _ = cap /* ERROR not constant */ ([4]float64{real(z)}) ) var ch chan [10]int @@ -390,13 +391,14 @@ func len3() { _ = len([4]int{x}) _ = len /* ERROR not constant */ ([4]int{f()}) _ = len /* ERROR not constant */ ([4]int{len([]int{})}) - _ = len /* ERROR not constant */ ([4]int{len([4]int{})}) + _ = len([4]int{len([4]int{})}) ) var y float64 var z complex128 const ( _ = len([4]float64{}) _ = len([4]float64{y}) + _ = len([4]float64{real(2i)}) _ = len /* ERROR not constant */ ([4]float64{real(z)}) ) var ch chan [10]int