Repository navigation
fix(perl): don't attribute an unrelated later block to a forward declaration - #1688
Merged
Merged
Conversation
…aration
_slice_by_braces's generic Mode-B fallback searches forward from a
func_start match for the next `{` within a bounded window. A bodyless
forward declaration (`sub GetASCII($);`, ends in `;`, no real definition
anywhere later in the file) has no `{` on its own declaration line, but the
window before the NEXT real sub/method keyword can contain an unrelated
`{`-opening block (confirmed on language-crucible's exiftool corpus: an
`END { Cleanup(); }` block a few lines after `sub GetASCII($);`). The
generic fallback wrongly attributed that unrelated block's body to
GetASCII, reporting a function that doesn't exist with a bogus body.
Added a perl-gated branch (mirrors objc-group-2's #1336 bodyless-prototype
rejection): scan forward tracking paren depth (perl legacy prototypes can
contain a semicolon internally, e.g. `sub Options($$;@)`, so a naive
first-`;`-wins scan would misfire), and skip the match entirely if a `;`
terminator is reached before a real `{` -- a genuine forward declaration,
out of func_start's scope, not a function with a body.
extra_functions 2 -> 1 (the GetASCII phantom is gone), found_functions/
args_exact_match unchanged for the dozens of correctly-handled forward
declarations elsewhere in the same file.
Fixes #1609
Co-Authored-By: Claude Sonnet 5 <[email protected]>
…-decl-brace # Conflicts: # tests/golden_master_audit.json # tests/golden_master_zero_dep_audit.json # tests/ruff_audit_baseline.json
squid-protocol
enabled auto-merge (squash)
August 15, 2026 20:41
…-decl-brace # Conflicts: # tests/golden_master_audit.json # tests/golden_master_zero_dep_audit.json # tests/ruff_audit_baseline.json
Contributor
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.
Summary
Fixes #1609.
_slice_by_braces's generic Mode-B fallback searches forward from afunc_startmatch for the next{within a bounded window. A bodylessforward declaration (
sub GetASCII($);, ends in;, no real definitionanywhere later in the file) has no
{on its own declaration line, but thewindow before the NEXT real
sub/methodkeyword can contain an unrelated{-opening block. Confirmed onlanguage-crucible/data/perl/exiftool/exiftool:The generic fallback wrongly attributed
END's 3-line body toGetASCII,reporting a function that doesn't exist with a bogus body/LOC/args.
Fix
Added a perl-gated branch (mirrors objc-group-2's #1336 bodyless-prototype
rejection): scan forward tracking paren depth (perl legacy prototypes can
contain a semicolon internally, e.g.
sub Options($$;@), so a naivefirst-
;-wins scan would misfire), and skip the match entirely if a;terminator is reached before a real
{-- a genuine forward declaration,out of
func_start's scope, not a function with a body.Verification
crucible_check.py --mode bothblessed via--update --yes(expectedcascading drift).
audit_check.py --ciclean.Type of change
detector.py)Differential Scan target
Perl parser corpus (exiftool) -- the same file the issue's measurements came from.
Co-Authored-By: Claude Sonnet 5 [email protected]