Type refinement rememberance for statically labeled variables assigned to Engine API.
Opened this issue · 0 comments
I apologize for the description, I tried to describe it the best way I could. I do not consider the whole behavior to be a bug, but the specific issue I've ran into, nor am I quite sure if this would be Roblox specific or applies directly to the independent Luau project. I'll file a bug report on the Developer Forums if deemed more appropriate there.
Overview
When referencing a variable which is refined in a calling function, that variable is now refined outside of the function logic. This is desired behavior. What is not desired is when the refinement occurs to variables which are statically labeled by the Engine and does not require further refinement by the end-user.
Current Result
DataContainerManager:LoadAsync(Key: number | string)
causes NewPlayer.UserId
to be refined to number | string
, when in fact the Engine should have it statically labeled as number
and thus not remember the refinement from the function call.
Expected Result
The Type Solver should be aware of the static labeling from the Engine and not assume Player.UserId
has been refined to number | string
when statically labeled as a singular type. If the Engine labeled Player.UserId
as number | string
, for example, then the refinement behavior should kick in. As an example, here is what I expect to happen when a variable is statically typed by the Engine: