-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Make grammar for switch cases unambiguous (or make it clear that it is) #2040
Labels
area-language
Dart language related items (some items might be better tracked at github.com/dart-lang/language).
Milestone
Comments
Added this to the M1 milestone. |
Addressed in 0.09. Added Done label. |
lrhn
added
Type-Defect
area-language
Dart language related items (some items might be better tracked at github.com/dart-lang/language).
labels
May 2, 2012
copybara-service bot
pushed a commit
that referenced
this issue
Aug 7, 2023
…st, tools Revisions updated by `dart tools/rev_sdk_deps.dart`. ecosystem (https://github.com/dart-lang/ecosystem/compare/97fc1a7..dfeda1a): dfeda1a 2023-08-01 dependabot[bot] Bump actions/labeler from 4.0.4 to 4.3.0 (#148) c341051 2023-08-01 dependabot[bot] Bump coverallsapp/github-action from 2.2.0 to 2.2.1 (#147) c1c8d1f 2023-08-01 Moritz Update health.yaml (#146) 31c5d21 2023-07-27 Devon Carew misc updates to the label management tool (#145) http (https://github.com/dart-lang/http/compare/4289e8b..7e9ed12): 7e9ed12 2023-08-01 dependabot[bot] Bump actions/labeler from 4.2.0 to 4.3.0 (#1000) e8e35db 2023-07-31 Alex James [java_http] send request body (#995) mockito (https://github.com/dart-lang/mockito/compare/b421775..ff79de6): ff79de6 2023-08-04 Nate Bosch Allow the latest package:analyzer native (https://github.com/dart-lang/native/compare/f0dc3e9..0187d0e): 0187d0e 2023-08-07 Daco Harkes [native_assets_cli] Rename `Asset` `name` to `id` (#113) 1b984c7 2023-08-07 Daco Harkes [native_assets_cli] Replace `TypeError`s with `FormatException`s (#112) b2b26db 2023-08-07 Daco Harkes [native_assets_builder] Stop throwing from BuildRunner (#108) c940ac8 2023-08-03 Daco Harkes [native_assets_builder] return build dependencies (#107) 63daab8 2023-08-03 Daco Harkes [native_assets_builder] Fix dry run directory structure (#110) 3f26f20 2023-08-01 dependabot[bot] Bump coverallsapp/github-action from 2.2.0 to 2.2.1 (#104) protobuf (https://github.com/dart-lang/protobuf/compare/d9e8a31..217c030): 217c030 2023-08-02 Ömer Sinan Ağacan Avoid holding onto the buffer when parsing unknown length-delimited fields (#863) shelf (https://github.com/dart-lang/shelf/compare/bd59ead..73edd2b): 73edd2b 2023-08-01 dependabot[bot] Bump actions/labeler from 4.2.0 to 4.3.0 (#370) sse (https://github.com/dart-lang/sse/compare/e241085..8cc5b11): 8cc5b11 2023-08-01 dependabot[bot] Bump nanasess/setup-chromedriver from 2.0.0 to 2.1.1 (#86) test (https://github.com/dart-lang/test/compare/92eb0f7..5d571d6): 5d571d64 2023-08-03 Nate Bosch Add --fail-fast flag (#2040) a9dcce29 2023-08-01 Nate Bosch Rerun publish workflow on more PR changes (#2070) 50d558b2 2023-08-01 dependabot[bot] Bump github/codeql-action from 2.20.1 to 2.21.2 (#2071) 9e124e9f 2023-07-31 Nate Bosch Prepare to publish (#2069) tools (https://github.com/dart-lang/tools/compare/af3fc99..f14bf2e): f14bf2e 2023-08-07 Elias Yishak Remove unused NoOp classes (#138) a2aa1c3 2023-08-07 Devon Carew add CI; update readme (#140) d424568 2023-08-06 Devon Carew add usage docs to package:cli_config (#141) 921611a 2023-08-03 Elias Yishak Survey handler feature (#109) Change-Id: Iee720272733822d11caf46adcae516f12f11abec Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/318801 Commit-Queue: Devon Carew <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Auto-Submit: Devon Carew <[email protected]>
This issue was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-language
Dart language related items (some items might be better tracked at github.com/dart-lang/language).
The grammar for a switch case is (effectively):
label? ('case' expression ':')+ statement*
Since statements* can be empty:
case 1:
case 2:
break;
can be parsed as both one case with two expressions or two cases with one expression each, and no statements on the first one.
The last parsing is most likely wrong (implementations, but not the spec, requires a case to not reach the end without an explicit abort, and I am being told that it's intended to become specified too).
The problem is likely that +/* repetitions don't have any precedence or associativity associated with them. If they were specified as preferring more matches over fewer, the above would have a preferred parsing.
(Or maybe I'm just missing the place where this is already written, in which case it bears repeating near the switch grammar).
Alternatively, change statement* to statement+. It only changes something for the very last case of a switch, which then can't end as "case 4:}".
If we require explicit aborts from all cases.
The text was updated successfully, but these errors were encountered: