Repository navigation
Conversation
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.
await f() ** 2is parsed asawait (f() ** 2):In Python,
awaittakes a primary, and the power operator takesawait_expr | primaryon its left (await_expr,power). So the tree should be(await f()) ** 2:awaitusedPREC.unary, which is belowPREC.power, so the grammar took the longer match. This givesawaitits own precedence betweenpowerandcall(PREC.await = 22,callmoves to 23). Calls, attributes and subscripts still bind inside theawaitoperand.Other inputs:
await x ** y ** zgives(await x) ** (y ** z)(right associative, as before).-x ** 2,await f(),not await x,-await x,x ** await f()andawait (f() ** 2)give the same trees as before.The change is a few lines in
grammar.jsand one corpus test (test/corpus/expressions.txt).src/was regenerated with tree-sitter 0.25.9, the CLI inpackage-lock.json. The generated files conflict with several open PRs (#336, #353, #354), so I expect they need regenerating when merged; I can rebase and regenerate on request.Tested with 0.25.9 on Windows:
tree-sitter testpasses (118 parses; the new test fails on current master and passes with this change), regenerating gives no diff, andeslint grammar.jsis clean. I did not run the "Parse examples" step (numpy/django/flask/cpython) or the Linux/macOS jobs. The last PR runs on this repository showaction_required/failurewith no jobs, so I do not expect hosted CI results on this PR either.I used an AI coding assistant to reproduce the issue and draft this text; I checked the results and edited it.