-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Parser gives bad error messages for >>>
in non->>>
-enabled code
#46886
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
Comments
I'm aware that it's non-trivial because // Add or remove to change behavior:
// @dart=2.12
extension on Symbol {
String operator >(_) => "Greater Than'd";
String call(_) => "Called";
}
void main() {
print(#>>>(2));
} changes what it does depending on whether If that's hard to get around, I think we'll be willing to accept breaking that code. (I can't come up with any other syntax than a |
I'm tentatively marking this as August stable - if we do have a fix, we should consider it for cherry-picking. @johnniwinther @jensjoha - do you have a sense yet on how hard this will be to fix? |
The change to implement this is non-trivial and the needed CLs will not be safe to cherry-pick, so I recommend that we punt this for a later release, if we want to do it at all. The underlying problem is that the choice to interpret |
So, not as easy as it seemed. An alternative might be (guessing here) to make the parser recognize |
Currently the parser doesn't know about nnbd settings, triple-shift-operator settings etc. So for one thing, making it know about it wouldn't be trivial, for another thing making it know about it seems like a step in the wrong direction. |
Does the parser need to know? (Why is the original error message asking for an identifier when any expression would work?) |
Alternatively, we can focus on making sure that the min SDK constraint is high enough for new apps that these new language features are available "out of the box". I already made this change for the Dart SDK: I could prepare a similar change for the Flutter SDK templates. |
Encouraging people to use higher SDK-constraints is fine, but won't help those who don't. If you have a 2.12 language version, a 2.13 SDK, and you write That's going to happen for a while. Since 2.12 was the last breaking change, there is no urgent need to increment your package's language version to 2.13 (or 2.14) until you actually want to use a feature from 2.13 (which means So, we can't avoid the error. This issue exists because the current error that you currently get is not that helpful. In order to give a better error message we need to recognize that someone is trying to write the Adding So, either we do that, or we somehow special case error recovery for |
#46886 Change-Id: Ib204d0c9a7116aaff0f0079be51d551c3f89316d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211003 Commit-Queue: Jens Johansen <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
Parser changed landed. |
@devoncarew to track @johnniwinther does @jensjoha 's change fix this issue or is there more to follow? |
The change improves the message in most use cases. See for instance the errors reported here. There is no additional work planned. |
OK, caught up on the thread. FYI, the cherry pick window for stable closes this monday 8/30, and we're very close to the release, so we need to raise our bar for things we'd cherry-pick. I'd suggest filing a cherry-pick request for this. We'd want to know that it can merge cleanly (or prepare a CL for the merge). We can then discuss on the cherry-pick request the pros and cons of cherry picking. @jensjoha / @johnniwinther - do you want to file the cherry-pick? |
…(part 2) #46886 Change-Id: I6195ad921f5c4b9622c735cb919c2d88f957f374 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211820 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
I think this can be closed. |
For a program like
compiling or analyzing with a 2.12 language version gives:
If we compare that to the error message for lacking extension methods:
would it be possible to give a similar useful error message for uses of
>>>
in language versions before it's enabled.The text was updated successfully, but these errors were encountered: