BruceSherwood/glowscript

false + 0 fails

Closed this issue · 4 comments

Consider the following seemingly-innocent program:

a = 3==4
print("yyyyy", a, 0, a+0, a==0)

*) Desired and expected behavior:
yyyyy False 0 0 True

This works as expected under python from the command line.
The corresponding javascript also works as expected. However...

*) Observed glowscript behavior: runtime error:
a['+'] is not a function

This is 100% reproducible chez moi.

There is some speculation as to how this might be related to issue #60.

BTW FWIW, 0+a works more-or-less as expected, even though a+0 fails.

OTOH a==0 and 0==a both fail.

Thanks for the additional clear test case. See later comments about RapydScript.

Unlike #60, this is not a rapydscript compiler issue. The following code

a = 3==4
print("ZZZZ", a, 0, a+0)

appears to compile and run OK when fed directly to RapydScript or rapydscript-ng.

However it throws runtime error when compiled via glowscript. The location of the error suggests the hypothesis that operator overloading might be part of the problem.

Correct. See my extended comment in #60.