Skip to content

Commit

Permalink
feat: ensure that untyped values are converted to the same type
Browse files Browse the repository at this point in the history
  • Loading branch information
secDre4mer committed Jan 6, 2025
1 parent e686f55 commit c74bccb
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 c74bccb

Please sign in to comment.