types2, go/types: record final type for min/max arguments

Fixes #60991

Change-Id: I6130ccecbdc209996dbb376491be9df3b8988327
Reviewed-on: https://go-review.googlesource.com/c/go/+/506055
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Cuong Manh Le 2023-06-25 22:59:33 +07:00 committed by Gopher Robot
parent ee361ce66c
commit b3ca8d2b3c
3 changed files with 23 additions and 0 deletions

View file

@ -578,6 +578,11 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
x.mode = value
}
// Use the final type computed above for all arguments.
for _, a := range args {
check.updateExprType(a.expr, x.typ, true)
}
if check.recordTypes() && x.mode != constant_ {
types := make([]Type, nargs)
for i := range types {

View file

@ -577,6 +577,11 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
x.mode = value
}
// Use the final type computed above for all arguments.
for _, a := range args {
check.updateExprType(a.expr, x.typ, true)
}
if check.recordTypes() && x.mode != constant_ {
types := make([]Type, nargs)
for i := range types {

View file

@ -0,0 +1,13 @@
// build
// Copyright 2023 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
import "math"
func f() {
_ = min(0.1, 0.2, math.Sqrt(1))
}