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
{{ message }}
Repository navigation
Type narrowing in ternary operator not working correctly #2233
In a ternary expression with type checking: "local a = type(x) == "something" and dosomething(x) or somethingelse(x)", the type should be narrowed for both cases
Actual Behaviour
The type is only narrowed for the first case (boolean here), in the second case it is still boolean or string
Activity
barrettruth commentedon Apr 9, 2026
For #2233 / #3154, I was able to replicate with:
I think the following MVP is appropriate:
extend the current
andRHS truthiness heuristic from literals to simple direct calls ONLY whose first documented return is definitely truthy.Scope:
name()calls liketostring(x), but only when all visible definitions document a truthy first returne.g. these are in scope:
to me this was broader than a
tostring()-only case but still conservative enough to avoid turning tracer into a second inference engine.@sumneko wdyt?