hedy
hedy copied to clipboard
[BUG] unexpected error when printing a variable name before variable definition, level 2 and 3
Describe the bug When you define a variable in line 2 and you want to print the variable name as text in line 1 you get an error.
Paste the Hedy code & level This code in level 3:
print I love animals
animals is dog, cat, mouse
print animals at random
raises this error:
We can't run your program.
You cannot use the command print with animals because it is a list. Try changing animals to text or a number.
This code in level 2 or 3:
print I love animals
animals is dog
print animals
raises this error:
Something went wrong while running the program.
name 'animals' is not defined
Expected behavior Variable names that are not defined yet should be printed as text. Although I can imagine that this is hard to implement on the interpretation side. If it to hard an appropriate error for these cases would be nice.
Yeah, we know! This is a duplicate of #165 but it is really hard to fix since it involves program analysis to see where a variable is used. I will try to work on this over Christmas