mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-29 22:02:42 +01:00
Adds a `LazyImportRef` instruction. Versus `CrossRef`, this is intended to represent an instruction which cannot be used directly, and must be replaced when it comes up due to name lookup. The intent is to use this to avoid recursive loading of imported IR instructions. Note, under this model, when `ResolveIfLazyImportRef` is called, it essentially needs to load both inst and type information to a sufficient point where any further attempts would hit name lookup again. That will probably be complex, and the current implementation is just touching the surface of the issue. I was heading down this route because it would mean we have a limited number of points that need to consider whether they're going to talk about a `LazyImportRef`. I'm considering whether `CrossRef` should be dropped in favor of more specific `Builtin` special-casing, due to the divergence of desired behaviors. This could mean dropping the `builtins` IR since it's not looking useful right now. Modify `NameScope` to track whether the scope is associated with a load error. This is to handle cases where one or more imports failed, so we do not want to issue warnings for related scopes. The 0-size on `ValueStore` comes up due to the changes to `NameScope`, which make it too large for the default handling. After discussion with zygoloid, the thought was we might want to try reserving a roughly correct value based on parse node counts, but the stack default wasn't buying much. Fixes a bug where the implicit import used the package name instead of the invalid identifier.