Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[next] flow-typing of return types at odds with polymorphic functions #768

Closed
hishamhm opened this issue Jul 25, 2024 · 2 comments
Closed
Labels
bug Something isn't working semantics Unexpected or unsound behaviors

Comments

@hishamhm
Copy link
Member

hishamhm commented Jul 25, 2024

local t: {string: string}
local s: string

local wat = {}
wat[true] = s:gsub("bla", t)
local t: {string:string} = {}
local s: string
if next(t, s) then
end
@hishamhm hishamhm added bug Something isn't working semantics Unexpected or unsound behaviors labels Jul 25, 2024
@hishamhm hishamhm changed the title emptytable autodetection at odds with polymorphic functions flow-typing of return types at odds with polymorphic functions Jul 25, 2024
@hishamhm hishamhm changed the title flow-typing of return types at odds with polymorphic functions [next] flow-typing of return types at odds with polymorphic functions Aug 26, 2024
hishamhm added a commit that referenced this issue Aug 26, 2024
Introduces a special internal type, to be used only as the node.expected
type in boolean contexts such as `if _ then`. It behaves exactly like
boolean except that type variables do not infer to it.

See #768.
@hishamhm
Copy link
Member Author

Commit e19725b fixes the second test case.

@V1K1NGbg this means that the latest next branch should support if next(foo) then without ~= nil. Can you give that a try?

hishamhm added a commit that referenced this issue Aug 31, 2024
Introduces a special internal type, to be used only as the node.expected
type in boolean contexts such as `if _ then`. It behaves exactly like
boolean except that type variables do not infer to it.

See #768.
@hishamhm
Copy link
Member Author

The first test case no longer fails either!

hishamhm added a commit that referenced this issue Oct 7, 2024
Introduces a special internal type, to be used only as the node.expected
type in boolean contexts such as `if _ then`. It behaves exactly like
boolean except that type variables do not infer to it.

See #768.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working semantics Unexpected or unsound behaviors
Projects
None yet
Development

No branches or pull requests

1 participant