joe-greenawalt / skulpt

Automatically exported from code.google.com/p/skulpt
Other
0 stars 0 forks source link

If statement within a try block causes a crash #114

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Run this code in Skulpt

print "Yo"
try:
    if 1 < 10 :
        print "qqq"
    print "zzz"
except:
    print "qqq"

The JavaScript fails.  I attach a screen shot of what I see at skulpt.org in 
Firefox with firebug on....

Original issue reported on code.google.com by c...@umich.edu on 17 Jan 2013 at 3:35

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Interestingly this code does not get a syntax error - but produces the wrong 
output:

print "Yo"
try:
    if 1 < 10 :
        print "qqq"
    print "zzz"
except:
    print "qqq"
else:
    pass
finally:
    pass

Its pretty clear that once inside the try block the stack is kind of messed up. 
 I looked at Grammar.txt and the try is clearly pretty special cased in terms 
of parsing.   Hard one to puzzle through.

Original comment by c...@umich.edu on 17 Jan 2013 at 4:57

GoogleCodeExporter commented 9 years ago
This code:

print "a"
try:
    i = int('val')
except:
    print "c"
print "d"

Which makes an error in the try block - get a message - "ReferenceError: goog 
is not defined" - I am guessing again that there is some kind of mis-matched 
bracing in the generated code.

Original comment by c...@umich.edu on 17 Jan 2013 at 5:11

GoogleCodeExporter commented 9 years ago
I believe I have fixed this here:

http://code.google.com/r/drchuck-skulpt-mods/source/detail?r=5729295665e16a8347a
0299a50a4e2b853e347e1

Original comment by drchuck on 18 Jan 2013 at 3:59