jacobaustin123 / Coral

The Coral Programming Language: a blazingly-fast, gradually-typed Python compiler with optional static typing for optimization and safety.
https://jacobaustin123.github.io/Coral/
Other
143 stars 6 forks source link

globals dont work lolol #3

Closed mlb2251 closed 5 years ago

mlb2251 commented 5 years ago

checked on latest SAST branch.

x = 5 def foo(): ... a=x ... return a ... SNameError: name 'x' is not defined

jacobaustin123 commented 5 years ago

Globals work now. Added sfunc-globals1.cl to SAST tests.

mlb2251 commented 5 years ago

<3

jacobaustin123 commented 5 years ago

Globals actually don't work.

x : int = 3

def foo():
    x = "hello"
    return x

foo()

fails, since it checks the type annotations for x even though its type annotation is in the global scope. To fix this, we are going to have to keep separate lists of locals and globals which don't duplicate each other, or modify the locals list to drop type annotations for all the globals in the local maps.

jacobaustin123 commented 5 years ago

Fixed. Globals work now.