mojo
mojo copied to clipboard
[BUG]: Accessing variable in uninitialized state does not produce in compile error
Bug description
I don't know if it is intentional, or not, but code:
let i: Int
print(i)
compiles fine and as a results gives: 22938856605
. I don't know if it is intentional, but it could result in very strange bugs. Much better will be just to raise error about trying to access not initialized variable. On Python 3.11 it gives:
NameError: name 'i' is not defined. Did you mean: 'id'?
River, can you dupe this out?
Thanks for filing this. This is essentially a duplicate of #15, in that right now top-level variables are treated a bit specially by the notebook environment. Ensuring that these variables get persisted messes a bit with how analyses for initialization/mutability/etc is done.
Thanks for taking a look @River707 . Closing in favour of #15