fix(extract): don't flag in-body function-like macro calls as parse gaps (#1071)#1135
Merged
Conversation
A function-like macro invocation whose argument is a type token — e.g. ALLOC(int, n) — makes tree-sitter's C/C++ grammar emit an ERROR node (it parses the type in expression position), which cbm_collect_error_regions recorded as a parse_partial coverage gap. But the macro is #defined in the same file and the call sits inside an already-extracted function body, so nothing is actually missing from the graph — it's a benign call the grammar can't parse without the preprocessor (#1071, systematic across allocation-macro-style codebases). Subtract an error region only when it both (a) contains an invocation of a file-defined function-like macro and (b) is fully enclosed by an extracted Function/Method body. Condition (b) keeps a TOP-LEVEL macro invocation that expands to a definition still flagged (#949: the generated def isn't in the original span), and fails safe — a benign top-level call stays flagged rather than a real gap being hidden. Tests: a type-arg macro call inside a function no longer reports parse_partial; a real in-body syntax error still does; #949/#946 preserved. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
DeusData
enabled auto-merge
July 16, 2026 16:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (#1071)
A function-like macro invocation whose argument is a type token — e.g.
SYNTH_ALLOC_ARRAY(char, n)— makes tree-sitter's C/C++ grammar emit an ERROR node (it parsescharin expression position).cbm_collect_error_regionsrecords that as aparse_partialcoverage gap, even though the macro is#defined in the same file and nothing is actually missing from the graph. The reporter found this systematic across an allocation-macro-style corpus (built-in-type first arg: 43/45 invocations flagged; pointer-type: 17/17).Fix
Subtract an error region only when it both:
NAME(of a file-defined function-like macro (aMacrodef that carries a parameter signature), andCondition (2) is the important guard. A top-level macro invocation is different — the macro may itself expand to a definition the original span doesn't contain (that's #949,
extract_cpp_preproc_macro_generated_callable_skipped), which must stay flagged. Restricting suppression to in-body calls keeps #949 honest and fails safe: a benign top-level call stays flagged rather than a real gap being hidden.Tests (reproduce-first, RED-verified)
extract_cpp_functionlike_macro_type_arg_no_false_parse_partial_issue1071— RED-verified: with the suppression neutralized the file reportsparse_incomplete=1, error_ranges=14-14; with the fix it's clean.extract_cpp_real_in_body_error_still_flagged_issue1071— a genuine in-body syntax error (int x = ;, no macro) still reportsparse_incomplete— proves the suppression is tight....issue949/...issue946parse-coverage tests preserved.Full
extraction(253) andpipeline(221) suites pass; lint-ci clean.Closes #1071.