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

Failures on Add tests for proposed version 2.32 changes to patterns. #52260

Closed
stereotype441 opened this issue May 4, 2023 · 0 comments
Closed
Assignees
Labels
area-fe-analyzer-shared Assigned by engineers; when triaging, prefer either area-front-end or area-analyzer. fe-analyzer-shared-parser Issues with the shared parser's handling of correct code

Comments

@stereotype441
Copy link
Member

There are new test failures on Add tests for proposed version 2.32 changes to patterns..

The tests

language/patterns/version_2_32_changes_error_test MissingCompileTimeError (expected Pass)

are failing on configurations

analyzer-asserts-linux
cfe-strong-linux
cfe-weak-linux
@stereotype441 stereotype441 added area-fe-analyzer-shared Assigned by engineers; when triaging, prefer either area-front-end or area-analyzer. fe-analyzer-shared-parser Issues with the shared parser's handling of correct code labels May 4, 2023
@stereotype441 stereotype441 self-assigned this May 4, 2023
copybara-service bot pushed a commit that referenced this issue May 12, 2023
… when/as.

In https://dart-review.googlesource.com/c/sdk/+/299400, the parser was
adjusted so that it no longer accepts `when` and `as` as the names for
variable patterns in cases where there is a possible ambiguity
(e.g. `int when` is not accepted as a pattern because `int` is a
legitimate pattern, therefore `when` could introduce a guard
clause). This change further prohibits `when` and `as` from being the
names of variable patterns or identifier patterns even in the case
where there is no ambiguity. This is in line with the discussion at
#52199 (comment),
and the spec change at
dart-lang/language#3033.

Three new error codes are introduced, to cover the three circumstances
in which `when` or `as` might be used illegally: in a declared
variable pattern, in an assigned variable pattern, or in an identifier
pattern. I've also added analyzer tests to ensure that the parser
recovers from these errors nicely. Unfortunately, nice error recovery
is only feasible in the non-ambiguous cases.

I've also updated the language test expectations in
`tests/language/patterns/version_2_32_changes_error_test.dart` to
reflect the new error messages, and added a few more examples of uses
of `when` and `as` that are still permitted.

Fixes: #52311

Bug: #52260
Change-Id: I30cb3a1ca627c6db3d281740fb59de74c4118c2b
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/301482
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-fe-analyzer-shared Assigned by engineers; when triaging, prefer either area-front-end or area-analyzer. fe-analyzer-shared-parser Issues with the shared parser's handling of correct code
Projects
None yet
Development

No branches or pull requests

1 participant