bug: Parses `[[deprecated]]` on enumerator incorrectly
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
Research direction
Start by running the supplied C++17 reproduction with tree-sitter 0.25.3 and compare its parse tree with the expected tree. Trace the grammar entry points for enum_specifier, enumerator_list, and attribute_declaration, then add coverage for the shown enum. Done means the attribute belongs to Tres and the valid input produces no ERROR node.
Written by the indexing model from the issue text.
Description
Did you check existing issues?
- I have read all the tree-sitter docs if it relates to using the parser
- I have searched the existing issues of tree-sitter-cpp
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)
tree-sitter 0.25.3
Describe the bug
tree-sitter doesn't seem to know what to do with [[deprecated]] on an enumerator (enumeration value), and it breaks the parser out of enum_specifier
Steps To Reproduce/Bad Parse Tree
(translation_unit [0, 0] - [6, 0]
(declaration [0, 0] - [5, 2]
type: (enum_specifier [0, 0] - [3, 6]
name: (type_identifier [0, 11] - [0, 18])
body: (enumerator_list [0, 19] - [3, 6]
(enumerator [1, 2] - [1, 9]
name: (identifier [1, 2] - [1, 5])
value: (number_literal [1, 8] - [1, 9]))
(enumerator [2, 2] - [2, 9]
name: (identifier [2, 2] - [2, 5])
value: (number_literal [2, 8] - [2, 9]))
(enumerator [3, 2] - [3, 6]
name: (identifier [3, 2] - [3, 6]))))
(attribute_declaration [3, 7] - [3, 21]
(attribute [3, 9] - [3, 19]
name: (identifier [3, 9] - [3, 19])))
declarator: (init_declarator [3, 21] - [3, 25]
declarator: (identifier [3, 21] - [3, 21])
value: (number_literal [3, 24] - [3, 25]))
declarator: (init_declarator [4, 2] - [4, 10]
declarator: (identifier [4, 2] - [4, 6])
value: (number_literal [4, 9] - [4, 10]))
(ERROR [4, 10] - [5, 1])))
Obviously ERRORs on valid c++(17) code are a problem, but also notice that the attribute_declaration is not a part of the enum
Expected Behavior/Parse Tree
I will try to make a valid valid parse tree, but please don't hold me to it:
(translation_unit [0, 0] - [6, 0]
(enum_specifier [0, 0] - [5, 1]
name: (type_identifier [0, 11] - [0, 18])
body: (enumerator_list [0, 19] - [5, 1]
(enumerator [1, 2] - [1, 9]
name: (identifier [1, 2] - [1, 5])
value: (number_literal [1, 8] - [1, 9]))
(enumerator [2, 2] - [2, 9]
name: (identifier [2, 2] - [2, 5])
value: (number_literal [2, 8] - [2, 9]))
(enumerator [3, 2] - [3, 10]
name: (identifier [3, 2] - [3, 6])
(attribute_declaration [3, 6] - [3, 20]
(attribute [3, 8] - [3, 18]
name: (identifier [3, 8] - [3, 18])))
value: (number_literal [3, 9] - [3, 10]))
(enumerator [4, 2] - [4, 10]
name: (identifier [4, 2] - [4, 6])
value: (number_literal [4, 9] - [4, 10])))))
Repro
enum class Numbers {
One = 1,
Two = 2,
Tres [[deprecated]] = 3,
Four = 4,
};
- Dominant language
- JavaScript
- Stars
- 453
- Forks
- 185
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tree-sitter/tree-sitter-cpp
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
tree-sitter/tree-sitter-cpp#371 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
tree-sitter/tree-sitter-cpp#368 ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 45/100
tree-sitter/tree-sitter-cpp#365 · 1 reaction ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
tree-sitter/tree-sitter-cpp#363 ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
tree-sitter/tree-sitter-cpp#359 ·
All issues in tree-sitter/tree-sitter-cpp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·