"Unknown type conversion variable" #2207
|
I frequently run into the issue of being unable to cast fields when calling constructors of a base class from a derived one, and I'm not sure if I'm doing something wrong. Here's a case that (I think) should work, however it doesn't. As a result I also get the diagnostic for wrong return type afterwards. ---@class MyClass
local MyClass = {}
---@class MyDerivedClass : MyClass
local MyDerivedClass = {}
---@return MyClass
function MyClass.Create()
return {}
end
---@return MyDerivedClass
function MyDerivedClass.Create()
local instance = MyClass.Create() ---@cast instance MyDerivedClass
return instance
endThe code is of course for demonstration purposes of the issue and not a functional OOP example. Would like to know if I'm doing something wrong or if this is a bug. |
Answered by
carsakiller
Sep 24, 2023
Replies: 2 comments 5 replies
Answer selected by
carsakiller
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment



This can be tracked in #2326.