luau icon indicating copy to clipboard operation
luau copied to clipboard

[New Solver] fails to track type state of explicitly assigned properties

Open OverHash opened this issue 2 months ago • 1 comments

Consider this code example:

type Item = {
	specialAttributes: { string }?
}

local myItem: Item = {}
myItem.specialAttributes = {}
table.freeze(myItem.specialAttributes) -- errors!

This produces a type error today:

TypeError: Type '{string}?' could not be converted into '{-  -}'

this error is clearly wrong -- we have explicitly defined myItem.specialAttributes, and so it's not possible for it to be {string}? -- it would now be {string}.

Note that in my case, myItem was sourced after iterating over a table, and so the specialAttributes assignment (and freeze) occurs inside the loop. There are obvious workarounds (like using table.freeze to wrap the assignment), but the core issue remains.

OverHash avatar Sep 13 '25 06:09 OverHash

Note: this might be a dupe of #1970, but I'm not sure that it's exactly the same.

OverHash avatar Sep 13 '25 06:09 OverHash