Closed lewis6991 closed 2 years ago
Looks like the error is always flagged at the last or
local enum Type
"add"
"change"
"delete"
end
local function foo(a: integer, b: integer): Type
return a == 0 and 'delete' or
b == 0 and ('add' as Type) or
'change'
end
this however passes the typechecker.
@lewis6991 should be fixed now! can you test master
in your codebase and check if things are working now?
Thanks a lot.
... however, I've now got a different error:
local enum TypeA
"a"
"b"
end
local record A
type: TypeA
end
local enum TypeB
"a"
"b"
"c"
end
local record B
type: TypeB
end
function M.foo(a: A): {B}
local bs = {}
bs[1] = {
type = 'c' or a.type,
}
return bs
end
in return value: got {record (type: string)} (inferred at ...), expected {B}
@lewis6991 for this second example, I think the inference engine is just not powerful enough to handle it, currently. I believe you didn't get an error before because the return
type wasn't being checked enough. A solution is to declare the array type explicitly:
local bs: {B} = {}
and then everything else flows nicely.
No problem.
So with that, everything is now clean.
Reports:
in return value: string is not a Type ()