Compiler Question: why invert token.Less to token.Greater
shiyuge opened this issue · 1 comments
shiyuge commented
in compiler.go:
Lines 144 to 153 in 6fc8053
It seems that <
is translated to >
when compiling tengo scripts. I wonder why. This makes BinaryOp() in user defined types to never execute LessEq and Less branch.
For example I have a custom defined type Number
, and
Number(14)>12
works because it would invokeNumber.BinaryOp
that I implementedNumber(12)<14
throws a runtime error, because compiler inverts this to14>Number(12)
in compilation process, and it would invokeInt.BinaryOp
and fail.
Are there any special design considerations behind this? Can I simply send a PR to remove this piece of logic in compiler?