c381425bd3
Expressions can also occur in patterns, either after an equality or relational operator (e.g. `== e`), or after `const` (though what's allowed after `const` is heavily restricted). We need to make sure that the expression parser doesn't greedily treat `=>` as introducing a function expression when parsing these constructs inside a switch expression. But it's ok to allow function expressions inside list patterns, map patterns, parenthesized patterns, and in the argument part of object patterns. (These will be rejected by a later stage of analysis because expressions inside of patterns must be const, and a function expression can't be const. But the parser should still accept them so that we can give useful error messages). Fixes #50591. Bug: https://github.com/dart-lang/sdk/issues/50591 Change-Id: I828555782f5bc8cb8aae8a3948849b7a75bdec57 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273286 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
49 lines
1.9 KiB
Plaintext
49 lines
1.9 KiB
Plaintext
beginCompilationUnit(f)
|
|
beginMetadataStar(f)
|
|
endMetadataStar(0)
|
|
beginTopLevelMember(f)
|
|
beginTopLevelMethod(, null, null)
|
|
handleNoType()
|
|
handleIdentifier(f, topLevelFunctionDeclaration)
|
|
handleNoTypeVariables(()
|
|
beginFormalParameters((, MemberKind.TopLevelMethod)
|
|
beginMetadataStar(x)
|
|
endMetadataStar(0)
|
|
beginFormalParameter(x, MemberKind.TopLevelMethod, null, null, null)
|
|
handleNoType(()
|
|
handleIdentifier(x, formalParameterDeclaration)
|
|
handleFormalParameterWithoutValue())
|
|
endFormalParameter(null, null, null, x, null, null, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod)
|
|
endFormalParameters(1, (, ), MemberKind.TopLevelMethod)
|
|
handleAsyncModifier(null, null)
|
|
beginSwitchExpression(switch)
|
|
handleIdentifier(x, expression)
|
|
handleNoTypeArguments())
|
|
handleNoArguments())
|
|
handleSend(x, ))
|
|
handleParenthesizedCondition((, null, null)
|
|
beginSwitchExpressionBlock({)
|
|
beginSwitchExpressionCase()
|
|
handleNoTypeArguments({)
|
|
beginLiteralString('x')
|
|
endLiteralString(0, :)
|
|
handleNoTypeVariables(()
|
|
beginFunctionExpression(()
|
|
beginFormalParameters((, MemberKind.Local)
|
|
endFormalParameters(0, (, ), MemberKind.Local)
|
|
handleAsyncModifier(null, null)
|
|
handleLiteralInt(0)
|
|
handleExpressionFunctionBody(=>, null)
|
|
endFunctionExpression((, })
|
|
handleRelationalPattern(==)
|
|
handleMapPatternEntry(:, })
|
|
handleMapPattern(1, {, })
|
|
handleLiteralInt(0)
|
|
endSwitchExpressionCase(null, =>, 0)
|
|
endSwitchExpressionBlock(1, {, })
|
|
endSwitchExpression(switch, })
|
|
handleExpressionFunctionBody(=>, ;)
|
|
endTopLevelMethod(f, null, ;)
|
|
endTopLevelDeclaration()
|
|
endCompilationUnit(1, )
|