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
local type A <const> = require("a")
-- local interface A
-- get_type: function(A): string
-- end
local type B <const> = require("b")
-- local interface B is A where self:get_type() == "b"
-- end
local b: A = {
get_type = function(): string return "b" end
}
local c: A = {
get_type = function(): string return "c" end
}
if c is B then
print("is B")
else
print("is not B")
end
The above code prints "is B" when it should print "is not B". If we stop using 'require' and place the contents of the files directly in the above code, then we correctly get "is not B". It seems that when included via files, the compiled lua code is this:
if type(c) == "table" then
print("is B")
else
print("is not B")
end
And when not using require it is this:
if c:get_type() == "b" then
print("is B")
else
print("is not B")
end
The text was updated successfully, but these errors were encountered:
The above code prints "is B" when it should print "is not B". If we stop using 'require' and place the contents of the files directly in the above code, then we correctly get "is not B". It seems that when included via files, the compiled lua code is this:
And when not using require it is this:
The text was updated successfully, but these errors were encountered: