This commit is contained in:
parent
bc58da6d49
commit
2c354c4a96
1 changed files with 9 additions and 4 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue