luau
luau copied to clipboard
No type error reported when readonly property is modified via compound assignment
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