|
|
|
|
|
by chrislattner
11 days ago
|
|
This is fixed in Mojo btw, using the latest nightly: ```
$ cat test.mojo
from std.utils import Variant def main():
var x : Variant[Int, Pointer[Int, ImmStaticOrigin]]
# set it to int
x = 12345
# get a reference to the int (dynamically checked).
ref elt_ref = x[Int] # Set it to the pointer.
x = "hello".unsafe_ptr()
# try to use the old reference to the int.
print(elt_ref)
$ mojo build x.mojo
test.mojo:8:11: error: use of invalidated interior reference 'x["value"]'
print(elt_ref)
^
test.mojo:5:27: note: origin was invalidated here
x = "hello".unsafe_ptr()
^
mojo: error: failed to run the pass manager
``` |
|