tree-sitter / tree-sitter/tree-sitter-cpp

bug: gtest's ASSERT_DEBUG_DEATH not treated as an expression_statement

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

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
453
Forks
185
PR merge metrics
No merged PRs in 30d

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.8 (f2f197b6b27ce75c280c20f131d4f71e906b86f7)

Describe the bug

google test's ASSERT_DEBUG_DEATH is not treated as an expression_statement like other test macros. See the picture from the treesitter playground:

Image

EXPECT_FALSE is correctly shown as an expression statement while ASSERT_DEBUG_DEATH leads to an error. It has to do with the initialization of the class inside the macro.

Steps To Reproduce/Bad Parse Tree
  1. use gtest's assert debug death macro with an initialization inside it.
  2. tree-sitter can't parse the code
Expected Behavior/Parse Tree

The macro is resolved to an expression statement

Repro
EXPECT_FALSE( bool );
ASSERT_DEBUG_DEATH( const class Class() , "" );

class MockStream {
  public:
    MockStream(){};
};

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start with the provided repro in the tree-sitter playground and compare the parse trees for EXPECT_FALSE and ASSERT_DEBUG_DEATH, focusing on the initialization inside the latter macro. The work is done when the ASSERT_DEBUG_DEATH example is parsed as an expression_statement without an error, while the surrounding class declaration remains correctly parsed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.