New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: Compiler Crash with Self Referential Variant #1837
Comments
More minimal version: from utils.variant import Variant
from memory.unsafe import Pointer
@value
struct Value(CollectionElement):
alias Variant = Variant[Float64, Pointer[Self]]
var _variant: Self.Variant
fn main():
pass outputs
with
|
I spent some time looking into this and it completely twists my brain. The problem is that we're infinitely recursing in the internal LowerLITTypes pass when lowering types and attributes involving Value. The issue is that we're recursively lowering attributes like vtable entries and other stuff that isn't part of hte struct layout itself, because it is recursively reachable through the type references in the !kgen.variant type attribute list, and we never go through a !kgen.pointer which would break the cycle. I'm not sure the right way to solve this. Perhaps handle vtable entries specially - they are fundamentally pointer like. There is something pointer like that I'm not understanding here. @weiweichen can you investigate this? |
Sure, I'll take a look. Also @willghatch, might also need some idea from you about vtables. |
Bug description
outputs:
Note that doing the following does not fix the issue:
It outputs:
And moving the alias beneath
Delegate
outputs this error instead:System information
The text was updated successfully, but these errors were encountered: