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
NoSuchMethodError.toString should handle _Type.call() case #27651
Comments
BTW, this should always be a static error (and a static error during AOT compilation, not a runtime one). Are you not seeing a static error? |
The current Dart specification is a little lacking about this particular case. The implementations are not treating it correctly as a "function expression invocation" either. If they did, it would be rewritten into The implementations instead convert it to That does mean that the spec doesn't make it a compile-time error yet. It should be a warning (and in dartpad, it is: "C is not a function"). |
I totally agree that the analyzer should do a better job of reporting this as well, but this issue is specifically about the exception that is thrown. |
https://codereview.chromium.org/2507493003/ improves the error message: e.g.
|
Fixers issue #27651 BUG= http://dartbug.com/27651 R=eernst@google.com, floitsch@google.com, fschneider@google.com Review URL: https://codereview.chromium.org/2444843002 .
...or maybe _Type.call() itself should be implemented and throw a NoSuchMethodError with an appropriate message.
This situation occurs when you have code that omits the "new" in a call like this:
Right now it says:
This is highly unclear and we've seen experienced Dart engineers in usability studies get mildly confused by it. We should instead say something like:
See also #27571.
The text was updated successfully, but these errors were encountered: