You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I have a class with a property named str. I also have a subclass which inherits from that class.
When reassigning the property of the subclass to its own value, it breaks the type detection. This bug only happens on inherited properties.
Here is an example with code:
--- MyClass--- @classMyClass--- @fieldstrstringMyClass= {}
MyClass.str="My str"--- Constructor of MyClass.--- @returnMyClassfunctionMyClass:new()
locale= {}
setmetatable(e, self)
self.__index=selfreturneend--- MySubClass--- @classMySubClass:MyClassMySubClass=MyClass:new()
MySubClass.str2="My str2"-- This works:MyClass.str=MyClass.strMySubClass.str2=MySubClass.str2-- This doesn't work:MySubClass.str=MySubClass.strprint(MySubClass.str) -- Prints "My str"
The value of MySubClass.str is shown as "unknown":
This is a trivial example, but in other contexts it can completely break type checking.
To reproduce
Create a class MyClass with an attribute str of a given type.
Create a subclass MySubClass inheriting from that class.
Assign the attribute of MySubClass to itself: MySubClass.str = MySubClass.str
Expected behavior MySubClass.str should still be recognized as a string after a reassignment to itself.
Environment:
OS: Windows 10 x64
Is WSL remote? No
Client: VSCode
Temporary Fix
I also found a temporary fix for this issue: repeating @field str string in every subclass:
Describe the bug
I have a class with a property named
str
. I also have a subclass which inherits from that class.When reassigning the property of the subclass to its own value, it breaks the type detection. This bug only happens on inherited properties.
Here is an example with code:
The value of

MySubClass.str
is shown as "unknown":This is a trivial example, but in other contexts it can completely break type checking.
To reproduce
MyClass
with an attributestr
of a given type.MySubClass
inheriting from that class.MySubClass
to itself:MySubClass.str = MySubClass.str
Expected behavior
MySubClass.str
should still be recognized as a string after a reassignment to itself.Environment:
Temporary Fix
I also found a temporary fix for this issue: repeating
@field str string
in every subclass:But this isn't ideal...
The text was updated successfully, but these errors were encountered: