hedyorg / hedy

Hedy is a gradual programming language to teach children programming. Gradual languages use different language levels, where each level adds new concepts and syntactic complexity. At the end of the Hedy level sequence, kids master a subset of syntactically valid Python.
https://www.hedy.org
European Union Public License 1.2
1.29k stars 284 forks source link

Confusing: level-1 reported when compiling on level fails #137

Closed rix0rrr closed 3 years ago

rix0rrr commented 3 years ago

See the new "run locally" functionality that was/is being added in #120.

Run the following program:

#level 5
print Hello world!

This is an incorrect program for level 5 (it's actually a level 1 program), so we are expecting to see a parse error. However, running it and printing the full error message is a little confusing:

$ python3 hedy.py test.hedy
An error occurred: Parse
level=4           <--- 🚨THIS IS CONFUSING
parse_error=No terminal defined for '!' at line 1 col 18

print hello world!
                 ^

Expecting: {'SPACE', '__ANON_8', '_EOL'}

What's happening is that on catching a parsing mistake, the parsing is retried on a level lower:

https://github.com/Felienne/hedy/blob/b4359bf202c952fd1d946e5a91a57abcbe2991b7/hedy.py#L633-L638

However, if parsing on level 4 also fails, THAT exception is not caught again but left to bubble up to the user, which is now very confusing because the final exception the user sees is about the failing parse at level 4, instead of the failing parse at level 5.

Felienne commented 3 years ago

yeah, I think for now we should disable the "fall back" compilation until it works better!