mojo icon indicating copy to clipboard operation
mojo copied to clipboard

[BUG]: Accessing variable in uninitialized state does not produce in compile error

Open gryznar opened this issue 1 year ago • 1 comments

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'?

gryznar avatar Jun 06 '23 00:06 gryznar

River, can you dupe this out?

lattner avatar Jun 06 '23 01:06 lattner

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.

River707 avatar Jun 12 '23 17:06 River707

Thanks for taking a look @River707 . Closing in favour of #15

Mogball avatar Jun 12 '23 23:06 Mogball