luau
luau copied to clipboard
Track the local binding that a prefixed type reference is linked to
Right now, all local bindings are nicely linked together as they share a pointer to the same AstLocal. But the same is not true for type references
Consider the following code:
local Types = require("path/to/types")
type Foo = Types.Foo
It would be nice to be able to link the Types in Types.Foo to the local definition.
Use case: if a user requests to rename the "Types" local variable, it should rename the imported type prefix (and vice versa).
From first glance, I think this is doable by storing the prefix as an AstLocal here, and tracking it appropriately:
https://github.com/luau-lang/luau/blob/74c532053f829d31bb000c16d3c12732e37dbf3f/Ast/include/Luau/Ast.h#L883-L899
Or maybe you have other ideas