Files
sdk/pkg/front_end/parser_testcases/patterns/functionExpression_disallowed_insideSwitchExpressionInWhenClause.dart.parser.expect
T
Paul Berry b0c705e4bd Set mayParseFunctionExpressions properly during switch expression parsing.
We need to prohibit function expressions during guard clauses in
switch expressions, otherwise the `=>` might be misinterpreted.

Fixes #50591.

Bug: https://github.com/dart-lang/sdk/issues/50591, https://github.com/dart-lang/language/issues/2672
Change-Id: Ie5703ac7049557798b19778281429e8a591cf09f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273020
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-12-01 18:57:33 +00:00

6 lines
390 B
Plaintext

f(x, y) => switch(x) { _ when y + () => 0 };
f[StringToken]([BeginToken]x[StringToken],[SimpleToken] y[StringToken])[SimpleToken] =>[SimpleToken] switch[KeywordToken]([BeginToken]x[StringToken])[SimpleToken] {[BeginToken] _[StringToken] when[KeywordToken] y[StringToken] +[SimpleToken] ([BeginToken])[SimpleToken] =>[SimpleToken] 0[StringToken] }[SimpleToken];[SimpleToken]
[SimpleToken]