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
The only case where the argument to convert will not be a string is when u itself is nil. But since u is R and u (-> type(u) == "table" and u) will never produce a nil, convert's argument is a string (well, string | nil).
In fact this error can be avoided by using and assert(u) instead of just and u.
I haven't dug around much in the fact inference code so I'm not sure how feasible it is to say a given variable should be truthy in a given context. Also with custom is implementations it may not be as simple as this, but it would be nice to not need a runtime assert for this.
The text was updated successfully, but these errors were encountered:
To make this work (i.e, given a , we would have to special-case the var is T and var or __ construct.
If the and part contains anything other than the plain variable tested with is, that part may be nil, and then the or part would still run when var is T (as shown in #776), so if var was of the type T | U, we can't assume U in the or part if the and part is an arbitrary expression. But we could for this special-cased construct you described.
(Possibly related to/duplicate of #776, or maybe a special case of it?)
Consider the following:
The only case where the argument to
convert
will not be a string is whenu
itself is nil. But sinceu is R and u
(->type(u) == "table" and u
) will never produce anil
,convert
's argument is astring
(well,string | nil
).In fact this error can be avoided by using
and assert(u)
instead of justand u
.I haven't dug around much in the fact inference code so I'm not sure how feasible it is to say a given variable should be truthy in a given context. Also with custom
is
implementations it may not be as simple as this, but it would be nice to not need a runtime assert for this.The text was updated successfully, but these errors were encountered: