Skip to content

Commit 1e3e91d

Browse files
secDre4mermvertes
andauthored
feat: ensure that untyped values are converted to the same type (#1677)
Co-authored-by: Marc Vertes <mvertes@free.fr>
1 parent 14d3137 commit 1e3e91d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

interp/typecheck.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ func (check typecheck) binaryExpr(n *node) error {
270270
}
271271
}
272272

273+
// Ensure that if values are untyped, both are converted to the same type
273274
_ = check.convertUntyped(c0, c1.typ)
274275
_ = check.convertUntyped(c1, c0.typ)
275276

@@ -1059,7 +1060,7 @@ func (check typecheck) convertUntyped(n *node, typ *itype) error {
10591060
// Both n and target are untyped.
10601061
nkind, tkind := ntyp.Kind(), ttyp.Kind()
10611062
if isNumber(ntyp) && isNumber(ttyp) {
1062-
if nkind < tkind {
1063+
if nkind <= tkind {
10631064
n.typ = typ
10641065
}
10651066
} else if nkind != tkind {

0 commit comments

Comments
 (0)