Merge pull request #300 from nspcc-dev/equal-numequal-fix-294
compiler: fix string/numbers equality/inequality gen again Closes: #294.
This commit is contained in:
commit
5bab4b8bb1
1 changed files with 9 additions and 1 deletions
|
@ -392,11 +392,19 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
|
||||||
}
|
}
|
||||||
case n.Op == token.EQL:
|
case n.Op == token.EQL:
|
||||||
// VM has separate opcodes for number and string equality
|
// VM has separate opcodes for number and string equality
|
||||||
if isStringType(tinfo.Type) {
|
if isStringType(c.typeInfo.Types[n.X].Type) {
|
||||||
emitOpcode(c.prog, vm.EQUAL)
|
emitOpcode(c.prog, vm.EQUAL)
|
||||||
} else {
|
} else {
|
||||||
emitOpcode(c.prog, vm.NUMEQUAL)
|
emitOpcode(c.prog, vm.NUMEQUAL)
|
||||||
}
|
}
|
||||||
|
case n.Op == token.NEQ:
|
||||||
|
// VM has separate opcodes for number and string equality
|
||||||
|
if isStringType(c.typeInfo.Types[n.X].Type) {
|
||||||
|
emitOpcode(c.prog, vm.EQUAL)
|
||||||
|
emitOpcode(c.prog, vm.NOT)
|
||||||
|
} else {
|
||||||
|
emitOpcode(c.prog, vm.NUMNOTEQUAL)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
c.convertToken(n.Op)
|
c.convertToken(n.Op)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue