Repository navigation
Keep decorator expressions in the AST when no class expression follows - #65796
Draft
Ryan Cavanaugh (RyanCavanaugh) wants to merge 3 commits into
Draft
Ryan Cavanaugh (RyanCavanaugh) wants to merge 3 commits into
Ryan Cavanaugh (RyanCavanaugh) wants to merge 3 commits into
Conversation
…ass expression Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an automated PR authored by GitHub Copilot using Claude Opus with default reasoning level.
Motivation & Guidance
Motivation: Copilot Coding Agent was assigned the issue.
Guidance: None beyond the issue. A rubber-duck review recommended wrapping the multi-decorator recovery in parentheses.
Analysis
Document highlights panics here with
did not expect KindVariableDeclaration to have KindIdentifier in its trivia.Since #65496,
parseDecoratedExpressionreturns a missing identifier when noclassfollows. That drops the parsed decorators, sodecis left in theVariableDeclaration's trivia, whichastnavasserts against. Going back to returning aMissingDeclarationwould contradict #65496, since a declaration isn't an expression.Fix
The "Expression expected" diagnostic is unchanged; only the returned node differs. It is built from the decorators' own expressions, with no lookahead:
x = @dec 1x = decx = @a @b 1x = (a, b)x = @a @b[0]x = (a, b)[0]ParenthesizedExpression. Without the wrapper, a bareBinaryExpressionwould be returned where a primary expression is expected.@a public @b) are dropped. Keyword tokens in trivia are fine forastnav.Baseline changes worth reviewing
decoratorOnArrowFunctionreturns to its pre-Return a missing identifier from parseDecoratedExpression when no class follows #65496 parse and errors, anddecoratorOnFunctionExpressiongets itsdecsymbol back.@dec()whendecrequires an argument.Tests
TestDocumentHighlightsDecoratorOnNonClassExpressioncovers the issue's two markers plus a two-decorator case.decoratorMissingClassExpression.tsgainsx = @a @b 1;andx = @a @b[0];.