mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 23:42:23 +00:00
compiler: fix string/numbers equality/inequality gen again
Unfortunately d58fbe0c88
didn't really fix the
problem because tinfo.Type (the expression resulting type) actually is a bool
and we need to check its parameters. Also, there is need to fix the NEQ
operation.
This commit is contained in:
parent
0574bcf1fe
commit
4ccda04eea
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:
|
||||
// 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)
|
||||
} else {
|
||||
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:
|
||||
c.convertToken(n.Op)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue