diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index eadad27d02..fec14870ef 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -302,12 +302,12 @@ const # magic checked op; magic unchecked op; checked op; unchecked op ["", "", "($1 <= $2)", "($1 <= $2)"], # LeB ["", "", "($1 < $2)", "($1 < $2)"], # LtB ["", "", "($1 == $2)", "($1 == $2)"], # EqRef - ["", "", "($1 == $2)", "($1 == $2)"], # EqProc ["", "", "($1 == $2)", "($1 == $2)"], # EqUntracedRef ["", "", "($1 <= $2)", "($1 <= $2)"], # LePtr ["", "", "($1 < $2)", "($1 < $2)"], # LtPtr ["", "", "($1 == $2)", "($1 == $2)"], # EqCString ["", "", "($1 != $2)", "($1 != $2)"], # Xor + ["", "", "($1 == $2)", "($1 == $2)"], # EqProc ["NegInt", "", "NegInt($1)", "-($1)"], # UnaryMinusI ["NegInt64", "", "NegInt64($1)", "-($1)"], # UnaryMinusI64 ["AbsInt", "", "AbsInt($1)", "Math.abs($1)"], # AbsI @@ -402,12 +402,12 @@ const # magic checked op; magic unchecked op; checked op; unchecked op ["", "", "($1 <= $2)", "($1 <= $2)"], # LeB ["", "", "($1 < $2)", "($1 < $2)"], # LtB ["", "", "($1 == $2)", "($1 == $2)"], # EqRef - ["", "", "($1 == $2)", "($1 == $2)"], # EqProc ["", "", "($1 == $2)", "($1 == $2)"], # EqUntracedRef ["", "", "($1 <= $2)", "($1 <= $2)"], # LePtr ["", "", "($1 < $2)", "($1 < $2)"], # LtPtr ["", "", "($1 == $2)", "($1 == $2)"], # EqCString ["", "", "($1 != $2)", "($1 != $2)"], # Xor + ["", "", "($1 == $2)", "($1 == $2)"], # EqProc ["NegInt", "", "NegInt($1)", "-($1)"], # UnaryMinusI ["NegInt64", "", "NegInt64($1)", "-($1)"], # UnaryMinusI64 ["AbsInt", "", "AbsInt($1)", "Math.abs($1)"], # AbsI diff --git a/compiler/semfold.nim b/compiler/semfold.nim index ca06ea1b66..ebde9a2be8 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -315,6 +315,7 @@ proc evalOp(m: TMagic, n, a, b, c: PNode): PNode = of mLtStr: result = newIntNodeT(ord(getStr(a) < getStr(b)), n) of mLeStr: result = newIntNodeT(ord(getStr(a) <= getStr(b)), n) of mEqStr: result = newIntNodeT(ord(getStr(a) == getStr(b)), n) + of mEqCString: result = newIntNodeT(ord(getStr(a) == getStr(b)), n) of mLtU, mLtU64: result = newIntNodeT(ord(`<%`(getOrdValue(a), getOrdValue(b))), n) of mLeU, mLeU64: diff --git a/tests/js/testmagic.nim b/tests/js/testmagic.nim new file mode 100644 index 0000000000..c58496dfd7 --- /dev/null +++ b/tests/js/testmagic.nim @@ -0,0 +1,10 @@ +discard """ + cmd: "nimrod js --hints:on -r $# $#" + output: '''true''' +""" + +# This file tests some magic + +const foo = cstring("foo") +const bar = cstring("foo") +echo(foo == bar)