Skip to content
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

Alias not queriable #3331

Closed
JoranHonig opened this issue May 1, 2024 · 3 comments
Closed

Alias not queriable #3331

JoranHonig opened this issue May 1, 2024 · 3 comments
Labels
bug query Related to tree-sitter queries executor

Comments

@JoranHonig
Copy link

Problem

I've defined an alias here: https://github.com/JoranHonig/tree-sitter-solidity/blob/master/grammar.js#L791

I'd expect to be able to query for binary_operator nodes as such:

  (binary_operator) @operator

Steps to reproduce

git clone [email protected]:JoranHonig/tree-sitter-solidity.git
tree-sitter generate

cat " (binary_operator) @operator" > example.scm
touch sample.sol
tree-sitter-query example.scm sample.sol

Expected behavior

No query error

Tree-sitter version (tree-sitter --version)

tree-sitter 0.22.4

Operating system/version

=

@JoranHonig JoranHonig added the bug label May 1, 2024
@amaanq
Copy link
Member

amaanq commented May 1, 2024

might be similar to #2641, don't remember exactly

@maxbrunsfeld
Copy link
Contributor

thanks for the report; I thought this was handled

@ObserverOfTime ObserverOfTime added the query Related to tree-sitter queries executor label May 4, 2024
@amaanq
Copy link
Member

amaanq commented May 15, 2024

your parser.c code is not up to date, that's the issue. it is currently using binaryOperator - see the diff of me generating using 0.20.6:

Screenshot 2024-05-15 at 3 58 06 PM

Also - I recommend not aliasing a choice of many operators under one uniform named node - it makes checking for the text/querying for specific kinds of operators a bit more annoying, it's better to tie them to a field called operator (which you already have), but leave it as-is as a terminal/token

@amaanq amaanq closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2024
@tree-sitter tree-sitter deleted a comment from kilex69 May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug query Related to tree-sitter queries executor
Projects
None yet
Development

No branches or pull requests

4 participants