-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
This is a tracking issue for an internal compiler change.
Currently, certain builtin types, such as std.builtin.ExportOptions, have two indices in the InternPool. The first is a special index, InternPool.Index.export_options_type, which is generated by AstGen when it needs to use the type as a result type. The second is the "resolved" type, created by Sema.getBuiltinType.
When Sema resolves field types, this difference means a new type has to be returned from Sema.resolveTypeFields, which is quite annoying, and could lead to issues with type equality checks requiring resolution. Additionally, Sema.resolveTypeLayout may perform field type resolution, but does not return a new type, meaning all use sites of this function may be incorrect.
The best solution to this is to give these types a consistent index in the InternPool. The index has to be well-known for AstGen to function, so it will be the same as the fixed index today. The difference is that when the type is resolved, we will not create a new IP index: instead, we will simply associate the resolved type with the existing index.
This might look like Sema changing the data in InternPool.items to transparently convert from the simple_type representation to a normal struct/enum/whatever representation. This shouldn't change any behavior: any type query that works on the simple representation can also work on the resolved representation.
Note that several instance of RLS for builtins in AstGen are currently disabled due to bugs triggered by the resolveTypeLayout issue mentioned above. Once this issue is resolved, these can be re-enabled (search for this issue number).