fix relative comparisons of float
All checks were successful
/ test (push) Successful in 49s

This commit is contained in:
Neemek 2026-07-11 10:18:32 +02:00
parent bc58da6d49
commit 2c354c4a96
Signed by: neemek
GPG key ID: 84FFE4D7D40AB25E

View file

@ -648,6 +648,11 @@ func (c *Compiler) compileBinary(binary *BinaryNode) error {
return err
}
inType, err := c.deduceSignature(binary.Left) // type(left) == type(right) because res is valid
if err != nil {
return err
}
switch binary.BinaryOperation {
case BinaryAddition:
if res.Type() == TypeString {
@ -685,25 +690,25 @@ func (c *Compiler) compileBinary(binary *BinaryNode) error {
c.add(InstructionNotEqual)
case BinaryLess:
if res.Type() == TypeFloat {
if inType.Type() == TypeFloat {
c.add(InstructionLessFloat)
} else {
c.add(InstructionLessInt)
}
case BinaryGreater:
if res.Type() == TypeFloat {
if inType.Type() == TypeFloat {
c.add(InstructionGreaterFloat)
} else {
c.add(InstructionGreaterInt)
}
case BinaryLessEqual:
if res.Type() == TypeFloat {
if inType.Type() == TypeFloat {
c.add(InstructionLessOrEqualFloat)
} else {
c.add(InstructionLessOrEqualInt)
}
case BinaryGreaterEqual:
if res.Type() == TypeFloat {
if inType.Type() == TypeFloat {
c.add(InstructionGreaterOrEqualFloat)
} else {
c.add(InstructionGreaterOrEqualInt)