-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Types passed to a higher-order function can get mixed up. #123
Types passed to a higher-order function can get mixed up. #123
Comments
Same issue of Flow's inference not being polymorphic enough. Seems like we need to incorporate your CFA2 work into our analysis! :) |
I didn't realize that Flow analyzes function calls context insensitively, and that one has to annotate explicitly for polymorphism. Thanks for the tip, it explains a lot in my examples. |
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed. |
Is the following another instance of this issue? function flip<A, B, R>(f: (a: A, b: B) => R): (b: B, a: A) => R {
return (b, a) => f(a, b);
}
function fconst<A, B>(x: A, _: B): A {
return x;
}
const g = flip(fconst);
const a1: string = g(1, "hello"); // error
const a2: number = g("hello", 1); // error |
Adding typing to the hof does fix it. Should this just be closed? |
Flow decides to require annotation for polymorphic functions a long time ago. |
Here, Flow warns that boolean and number are incompatible. Also, it warns that we may be passing a string to minus.
The text was updated successfully, but these errors were encountered: