From 810f096811429d074d64715fa1d0ceb1f205cbd1 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 15 Aug 2019 18:22:56 +0300 Subject: [PATCH] compiler: change codegen to emit NUMEQUAL instead of EQUAL This is wrong, see issue #294, but it makes our VM tests work (as VM is missing EQUAL implementation), so until #294 is properly resolved we're better have this kind of wrong code generation. --- pkg/vm/compiler/codegen.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/vm/compiler/codegen.go b/pkg/vm/compiler/codegen.go index 45993eb37..b819da95d 100644 --- a/pkg/vm/compiler/codegen.go +++ b/pkg/vm/compiler/codegen.go @@ -705,11 +705,10 @@ func (c *codegen) convertToken(tok token.Token) { case token.GEQ: emitOpcode(c.prog, vm.GTE) case token.EQL: - // It seems that (looking to the python compiler) that comparing for - // equal (==) needs to return the instruction EQUAL. Where comparing - // (anything) to not equal (!=) needs to use the opcode NUMNOTEQUAL - // even for comparing strings. - emitOpcode(c.prog, vm.EQUAL) + // TODO: this is wrong (and the next one also is), see issue #294 + // Changing it EQUAL is not that big of an improvement, so we're + // using NUMEQUAL for now + emitOpcode(c.prog, vm.NUMEQUAL) case token.NEQ: emitOpcode(c.prog, vm.NUMNOTEQUAL) case token.DEC: