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 and operator seems to always infer a and b to be of type boolean | typeof(b) which does not reflect the actual runtime values as can be seen below.
This allows code like this to check correctly while in practice will return nil instead of false if i is nil.
The text was updated successfully, but these errors were encountered:
We are working on a fix for this, where we will only take nil and false parts of the left-hand side type if they are possible for that type.
So number? and number will still be number? and number? and boolean will be boolean?.
However, the fix might take some time to get here.
* Type inference of `a and b` and `a or b` has been improved (Fixes#730)
* Improved error message when `for ... in x` loop iterates over a value
that could be 'nil'
* Return type of `next` not includes 'nil' (Fixes#706)
* Improved type inference of `string` type
* Luau library table type names are now reported as `typeof(string)`/etc
instead of just `string` which was misleading
* Added parsing error when optional type alias type parameter wasn't
provided after `=` token
* Improved tagged union type refinement in conditional expressions, type
in `else` branch should no longer include previously handled union
options
* Type inference of `a and b` and `a or b` has been improved (Fixesluau-lang/luau#730)
* Improved error message when `for ... in x` loop iterates over a value
that could be 'nil'
* Return type of `next` not includes 'nil' (Fixesluau-lang/luau#706)
* Improved type inference of `string` type
* Luau library table type names are now reported as `typeof(string)`/etc
instead of just `string` which was misleading
* Added parsing error when optional type alias type parameter wasn't
provided after `=` token
* Improved tagged union type refinement in conditional expressions, type
in `else` branch should no longer include previously handled union
options
The
and
operator seems to always infera and b
to be of typeboolean | typeof(b)
which does not reflect the actual runtime values as can be seen below.This allows code like this to check correctly while in practice will return
nil
instead offalse
ifi
isnil
.The text was updated successfully, but these errors were encountered: