Closed tamasfe closed 2 years ago
Speaking of "dangling references" worry me... is this from unsafe
Rust? Because safe Rust should really have them...
I don't think there's any significant unsafe code right now. Most data in the HIR is stored in slotmaps (arenas), hierarchies and references are achieved by storing indexes to data.
Ah ok. So you mean an index that refers to data that is no longer valid. I suppose you can just substitute ?
for now?
Alright I just did that, it's in the phase where we resolve all type aliases, so it's a form of garbage collection. I did not touch related code anywhere else, so we will still panic on bugs where types are expected to exist.
Types are handled slightly differently compared to symbols, the relationships (references/aliases) between them are not as clear and aren't tracked. So when a type is removed we might end up having dangling references to it which currently result in a panic.
We either need to track references, properly update them and keep the current panicking behaviour to catch bugs (the hard way), or return the builtin unknown type any time a type is requested that does not exist (the easy way).