Skip to content

Commit

Permalink
feat: ensure that untyped values are converted to the same type (#1677)
Browse files Browse the repository at this point in the history
Co-authored-by: Marc Vertes <mvertes@free.fr>
  • Loading branch information
secDre4mer and mvertes authored Jan 8, 2025
1 parent 14d3137 commit 1e3e91d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion interp/typecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ func (check typecheck) binaryExpr(n *node) error {
}
}

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

Expand Down Expand Up @@ -1059,7 +1060,7 @@ func (check typecheck) convertUntyped(n *node, typ *itype) error {
// Both n and target are untyped.
nkind, tkind := ntyp.Kind(), ttyp.Kind()
if isNumber(ntyp) && isNumber(ttyp) {
if nkind < tkind {
if nkind <= tkind {
n.typ = typ
}
} else if nkind != tkind {
Expand Down

0 comments on commit 1e3e91d

Please # to comment.