luau icon indicating copy to clipboard operation
luau copied to clipboard

No type error reported when readonly property is modified via compound assignment

Open nothing1649 opened this issue 9 months ago • 0 comments

As of version 0.664, writing to a readonly property using a compound assignment statement does not cause a type error. Writing the assignment as t.p = t.p + 1 does not cause this issue.

--!strict
type readonly = {read field: number}
local t:readonly = {field = 1}
t.field *= -1 --no type error reported
t.field = t.field * -1 --correct type error

nothing1649 avatar Mar 13 '25 02:03 nothing1649