luau-lang / luau

A fast, small, safe, gradually typed embeddable scripting language derived from Lua
https://luau.org
MIT License
3.97k stars 373 forks source link

definitionModuleName is undefined for table type aliases #1441

Open checkraisefold opened 3 hours ago

checkraisefold commented 3 hours ago

definitionModuleName is only defined in the case of an explicit table definition using AstExprTable. However, when a TableType is resolved from an AstStatTypeAlias with an AstTypeTable contained, no definitionModuleName is filled in initially. This is an issue for anything that resolves a table type without an AstExprTable really, but that's mostly limited to type aliases.

The constraint solver is supposed to fill this in later for specifically type aliases, but it's currently a TODO item since Luau 539, which for the informed reader was released in August of 2022. I think an issue is appropriate to track this rather than having to track down a TODO item for it. https://github.com/luau-lang/luau/blob/master/Analysis/src/ConstraintSolver.cpp#L1104 The other issue with this location is that TypeAliasExpansionConstraint is not always used for type aliases, so an additional fix will be needed elsewhere.

This is problematic because existing (major) code depends on this, namely luau-lsp, and this behavior is not present in the old solver (the type alias has the correct definitionModuleName) and this causes luau-lsp tests to fail. https://github.com/JohnnyMorganz/luau-lsp/blob/main/src/operations/Completion.cpp#L373

checkraisefold commented 3 hours ago

needs new solver label