It looks like there's an inconsistency with how nested record metatables are handled (or maybe I got something wrong).
This works:
local record Outer
metamethod __call: function(container: Outer, instance: Outer): Outer
end
setmetatable(Outer, {
__call = function(container: Outer, instance: Outer): Outer
return setmetatable(instance, {__index = container})
end
})
This doesn't work:
local record Wrapper
record Inner
metamethod __call: function(container: Inner, instance: Inner): Inner
end
end
setmetatable(Wrapper.Inner, {
__call = function(container: Wrapper.Inner, instance: Wrapper.Inner): Wrapper.Inner
return setmetatable(instance, {__index = container})
end
})
The second example fails with:
argument 2: type parameter <A>: got Wrapper.Inner, expected record ()
It looks like there's an inconsistency with how nested record metatables are handled (or maybe I got something wrong).
This works:
This doesn't work:
The second example fails with: