Open hishamhm opened 1 month ago
Local variables are not being inferred to string, even though both sides of the and-or "ternary" resolve to string.
This is not true. Consider the case where cv
is a record, but cv.string
resolves to nil:
local cv: AliasVersion | string = {}
local a = cv is vers.NestedVersion and cv.string or cv
local b = cv is AliasVersion and cv.string or cv
print(type(a)) --> "table"
print(type(b)) --> "table"
This can only be solved when nil
is handled separately from other types. If we can guarantee that cv.string
is a non-nil string, then we'd know for a fact that all types other than nil
and boolean
are always truthy, and then we could propagate the inference confidently.
Local variables are not being inferred to
string
, even though both sides of the and-or "ternary" resolve to string.