mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: fix type checking of "make" arguments
As part of type checking make's arguments, we were converting untyped float and complex constant arguments to integers. However, we were doing this without concern for whether the argument was a declared constant. Thus a call like "make([]T, n)" could change n from an untyped float or untyped complex to an untyped integer. The fix here is to simply change checkmake to not call SetVal, which will be handled by defaultlit anyway. However, we also need to properly return the defaultlit result value to the caller, so checkmake's *Node parameter is also changed to **Node. Fixes #41680. Change-Id: I858927a052f384ec38684570d37b10a6906961f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/257966 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
c4971a14a7
commit
ad0ab812f8
2 changed files with 30 additions and 7 deletions
21
test/fixedbugs/issue41680.go
Normal file
21
test/fixedbugs/issue41680.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// compile
|
||||
|
||||
// Copyright 2020 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package p
|
||||
|
||||
func F(s string) bool {
|
||||
const m = 16
|
||||
const n = 1e5
|
||||
_ = make([]int, n)
|
||||
return len(s) < n*m
|
||||
}
|
||||
|
||||
func G() {
|
||||
const n = 1e5
|
||||
_ = make([]int, n)
|
||||
f := n
|
||||
var _ float64 = f
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue