Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

bug: namespace_definition and attributes issue

Open
#376 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp, javascript
Domain
compilers

Research direction

The namespace_definition rule lives in grammar.js, so start there and check where attribute_specifier is already allowed in neighbouring rules. Add optional attribute specifiers before and after the name, regenerate the parser, and confirm both repro snippets in the issue parse without ERROR nodes. Done means a corpus test in test/corpus covering both placements passes with tree-sitter test.

Written by the indexing model from the issue text.

Description

bug
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)

0.27.0

Describe the bug

namespace_definition symbol should be completed with optional($.attribute_specifier) before and after name field.

Steps To Reproduce/Bad Parse Tree

try to put legal c++ namespace definition to namespace __attribute__ (( __visibility__ ( default ))) ns {} to standard playground and you will get syntax error. The attribute specifier should be optionally accepted before and after name. This code copy-pasted from linux std include dir.

Expected Behavior/Parse Tree

no error

Repro
namespace __attribute__ (( __visibility__ ( default ))) ns {}  // Code that causes a parse error
namespace ns __attribute__ (( __visibility__ ( default ))) {}  // Code that causes a parse error too
}
Dominant language
JavaScript
Stars
459
Forks
190
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tree-sitter/tree-sitter-cpp

All issues in tree-sitter/tree-sitter-cpp

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.