philhassey / tinypy

Automatically exported from code.google.com/p/tinypy
http://www.tinypy.org/
Other
232 stars 51 forks source link

Specific conditional tests failing in a loop #22

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run the following code:

x = [1, 2, 3]

for i in x:
    if i != 0 and i:
        print("abc")

What is the expected output? What do you see instead?

The expected output is "abc". Instead, tinypy prints:

Exception:
assert failed

What version of the product are you using? On what operating system?

Tested on both Slackware Linux 10 and Windows XP SP2 with the latest
revision (r74).

Please provide any additional information below.

The bug does not show up if the tests are made in different order, i.e. 

"if i and i != 0:"

Also, the erroneous behaviour shows up regardless of what logical operator
is used (as far as I could figure) and the truthfulness of the expression
(happens in cases where it is false too). It does not happen with only a
single expression (only in expressions combined with 'or', 'and', etc). It
also doesn't happen when the conditional expression is done on a 'normal'
variable outside the loop.

Original issue reported on code.google.com by denis.ka...@gmail.com on 4 Jul 2008 at 6:03

GoogleCodeExporter commented 8 years ago
Actually, further tests show that even though "if i and i != 0:" (the reversed
expression I gave as an example) works, the "if i and i > 0:" (for instance) 
fails,
but not with the message given above. Instead, it prints nothing. Also, the 
expected
output is of course "abc\nabc\nabc\n", not "abc". Sorry about that.

The bug seems to be tied specifically to the single "i" truthfulness part of the
test, since the "if i > 0 and i != 0:" seems to be working fine.    

Original comment by denis.ka...@gmail.com on 4 Jul 2008 at 6:10

GoogleCodeExporter commented 8 years ago
I believe this error is likely due to a register allocation bug.  This can be
verified by commenting out the try/except in encode.py:do .. If that is the 
case, I
will probably work on resolving this bug when I have a moment.

Original comment by philhas...@gmail.com on 9 Jul 2008 at 2:15

GoogleCodeExporter commented 8 years ago

Original comment by philhas...@gmail.com on 5 Sep 2008 at 5:12

GoogleCodeExporter commented 8 years ago

Original comment by philhas...@gmail.com on 6 Sep 2008 at 3:27