Macros are not correctly parsed
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
I tried this code:
macro_rules! itemizer {
() => {
struct S;
impl S {
fn new() -> S { S }
}
}
}
I expected to see this happen:
Compiles correctly, but the AST should consider it as "not semicoloned".
Instead, this happened:
It compiles correctly but is considered to have a semicolon. Therefore the tokenstream dumper cannot rely on "is_semicoloned" to guess wether a semicolon shall output.
A simple fix would be rust-parse-impl.h line 1801
return AST::MacroInvocation::Regular (std::move (invoc_data),
std::move (outer_attrs),
- macro_locus, true);
+ macro_locus, false);
But it breaks the testsuite since the semicolon status is relied on with a different behavior during the macro expansion.
Meta
- e7ea5fb64026c72f4f93e1ecd92ce7e5d2941b54
Contributor guide
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.
Research direction
Start at rust-parse-impl.h line 1801 and inspect AST::MacroInvocation::Regular, then run the affected testsuite cases around macro expansion and semicolon handling. Trace how the tokenstream dumper uses is_semicoloned. Done means the AST records the macro invocation's semicolon status correctly without breaking the existing testsuite behavior during expansion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100