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
Analyzer error message is unclear when a generic function is used as a type argument #34741
Comments
It doesn't make sense to say However, it is true that it is a compile-time error to pass a generic function type as a type argument so The output from So we have considerations about the analyzer as well as the front end here. It's inconvenient that we cannot pass any term that denotes a generic function type as a type argument to typedef F<X extends num> = ... some generic function type that we want to test ...;
typedef F_expected = void Function<Y extends num>(Map<String, Y>);
main() {
print(F == F_expected);
} I think it might be helpful to report the issues separately: (1) the front end drops the type argument from the function type (at least when it's printed), and (2) the front end doesn't prevent |
Regarding the last paragraph of @eernstg's comment, agreed. I'm going to file a separate bug for issues (1) and (2), and let this bug represent issue (3). |
Regarding (1), I'm either unable to reproduce this bug, or I'm not understanding it. When I try running this code in the VM: typedef G = Function<X extends num>();
typedef G1<X> = Function();
main() {
print(G);
print(G1);
} The output I get is:
...which I believe is correct. @eernstg, I suspect I'm not understanding what you're getting at. Would you mind filing a separate issue under area-front-end to track the problem you're seeing? Regarding (2), there is already a bug filed for this: #30931 I'm going to re-title this bug now so that it represents (3) (unclear analyzer error message) and update its labels accordingly. |
I did not reproduce that behavior here, I just commented on the reported behavior. So, having #30931 for (2) and this one for (3), we're done! ;) |
R=brianwilkerson@google.com Bug: #34741 Change-Id: If766d0aad5d87578a578849f269746a64430a68b Reviewed-on: https://dart-review.googlesource.com/c/84100 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Dart SDK Version: 2.1.0-dev.6.0
OS: Windows 10
Analyzer doesn't allow function to use type parameter '<Instance of 'TypeParameterMember'>' as a type argument whereas dart does allow this.
Here is a sample code example:
Dart passes both with G and G1, sample output is:
Analyzer passes with G1 and fails with G. Here is a sample output:
I believe analyzer and dart should behave in the same manner, i.e. both should not (or maybe both should) throw a compile error here.
The text was updated successfully, but these errors were encountered: