Repository navigation
fix(objc): recognize untyped keyword-message args, stop body leak into args count - #1371
Merged
Merged
Conversation
…o args count Fixes #1335. Objective-C's `args` regex required a `(Type)` cast after every `label:`, so older untyped keyword-message style (`- back:sender`, defaulting to `id`, common in 1990s NeXTSTEP-era code) matched zero segments and silently undercounted to args=0. Adding a mandatory-label/no-type alternative to recognize this shape also reopened a "Ghost Args" risk: since `args_pattern.search()` scanned a function's whole body (not just its signature), once a signature matched no branch, the search fell through and matched the first later C-style-shaped call/statement in the body instead (confirmed: `Anchor.m`'s zero-arg `free` measured args=1 borrowed from its own `free(Address)` call; `HyperManager.m`'s 1-param `closeOthers:sender` measured args=2 borrowed from an unrelated `printf(...)` call). Closes that gap with an Invocation Shield: `_slice_by_braces` now bounds the args search to just the matched method's own signature text (via a new `args_search_text` param on `_calculate_block_metrics`), never the body, for objc's two func_start branches. This also makes the new untyped-param regex shape safe in the real pipeline even though, tested in isolation, it still matches body-only lookalikes (goto labels, ternaries, keyword-message sends) that are lexically identical to a real untyped param -- documented as known, pipeline-shielded limitations in the adversarial test gauntlet, same pattern as the existing comment/string-lookalike limitation. Also removes the stale duplicate `objective-c` block from the legacy tests/extraction/test_args_extraction.py (pre-epic-#813 monolithic file), fully superseded by tests/extraction/languages/test_objectivec.py. Golden master fixtures re-blessed via update_golden_master.py --yes: objc files in the language-crucible corpus now report correct Function Parameters counts (e.g. HyperManager.m 29->73), with expected small downstream ripple in unrelated files' 3D coordinates/PageRank-derived fields from the overall graph recalculation. Co-Authored-By: Claude Sonnet 5 <[email protected]>
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 #1335. Two related bugs in Objective-C's
argsextraction:argsregex required a(Type)cast after everylabel:, so older, still-valid untyped keyword-message style (- back:sender, defaulting toid, common in 1990s NeXTSTEP-era code) matched zero segments. Confirmed againstlanguage-crucible/data/objective-c/worldwideweb/HyperManager.m(~20 such methods in one file).args_pattern.search()scanned a function's whole body rather than just its signature, once a signature matched no branch (a genuinely zero-arg method, or an untyped param pre-fix), the search fell through and grabbed the first later C-style-shaped call/statement in the body instead — e.g.Anchor.m's zero-argfreemeasured args=1 (borrowed from its ownfree(Address)call), andHyperManager.m's 1-paramcloseOthers:sendermeasured args=2 (borrowed from an unrelatedprintf(...)call).Fix
argsregex, additive alongside the existing typed (label-optional) alternative -- fixes (1) without touching any previously-tested typed shape._slice_by_bracesnow bounds the args search to just the matched method's own signature text (a newargs_search_textparam on_calculate_block_metrics), never the body, for objc's twofunc_startbranches -- structurally fixes (2) regardless of (1).objective-cblock from the legacytests/extraction/test_args_extraction.pymonolithic file, fully superseded bytests/extraction/languages/test_objectivec.py.update_golden_master.py --yes(both full-precision and zero-dependency modes) -- objc files in the crucible corpus now report correct Function Parameters counts, with expected small downstream ripple in unrelated files' 3D coordinates/PageRank-derived fields from graph recalculation.Test plan
tests/extraction/languages/test_objectivec.py+test_objectivec_strict.py-- extended with new valid untyped-param cases and documented known-limitation teststests/core_engine/test_detector.py-- extendedARGS_COUNT_FIXTURES["objective-c"]and addedtest_objectivec_args_body_lookalikes_excluded_by_signature_boundpinning the exact confirmed corpus shapespytest tests/suite: 6844 passedpython tests/tools/audit_check.py: ruff/mypy/dead-key/ast-accuracy all cleanpython tests/tools/crucible_check.py: full_precision + zero_dependency both PASS after re-blessing golden masters🤖 Generated with Claude Code