Skip to content

Commit b3ca8d2

Browse files
cuonglmgopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Cuong Manh Le <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent ee361ce commit b3ca8d2

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/cmd/compile/internal/types2/builtins.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,11 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
578578
x.mode = value
579579
}
580580

581+
// Use the final type computed above for all arguments.
582+
for _, a := range args {
583+
check.updateExprType(a.expr, x.typ, true)
584+
}
585+
581586
if check.recordTypes() && x.mode != constant_ {
582587
types := make([]Type, nargs)
583588
for i := range types {

src/go/types/builtins.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,11 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
577577
x.mode = value
578578
}
579579

580+
// Use the final type computed above for all arguments.
581+
for _, a := range args {
582+
check.updateExprType(a.expr, x.typ, true)
583+
}
584+
580585
if check.recordTypes() && x.mode != constant_ {
581586
types := make([]Type, nargs)
582587
for i := range types {

test/fixedbugs/issue60991.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// build
2+
3+
// Copyright 2023 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package p
8+
9+
import "math"
10+
11+
func f() {
12+
_ = min(0.1, 0.2, math.Sqrt(1))
13+
}

0 commit comments

Comments
 (0)