Skip to content

fix(objc): recognize untyped keyword-message args, stop body leak into args count - #1371

Merged
squid-protocol merged 1 commit into
mainfrom
fix/objc-args-untyped-and-body-leak-1335
Aug 12, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/objc-args-untyped-and-body-leak-1335

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Fixes #1335. Two related bugs in Objective-C's args extraction:

  1. Untyped keyword-message params undercounted to 0. The args regex required a (Type) cast after every label:, so older, still-valid untyped keyword-message style (- back:sender, defaulting to id, common in 1990s NeXTSTEP-era code) matched zero segments. Confirmed against language-crucible/data/objective-c/worldwideweb/HyperManager.m (~20 such methods in one file).
  2. Body content leaking into the count. Because 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-arg free measured args=1 (borrowed from its own free(Address) call), and HyperManager.m's 1-param closeOthers:sender measured args=2 (borrowed from an unrelated printf(...) call).

Fix

  • Added a mandatory-label/no-type alternative to the objc args regex, additive alongside the existing typed (label-optional) alternative -- fixes (1) without touching any previously-tested typed shape.
  • Added an "Invocation Shield" for this pillar: _slice_by_braces now bounds the args search to just the matched method's own signature text (a new args_search_text param on _calculate_block_metrics), never the body, for objc's two func_start branches -- structurally fixes (2) regardless of (1).
  • This bounding is also what makes the new untyped-param shape safe: tested in isolation the regex still matches lexically-identical body-only lookalikes (goto labels, ternaries, keyword-message sends), which is now a documented, pipeline-shielded limitation in the adversarial test gauntlet (same pattern as the pre-existing comment/string-lookalike limitation).
  • Removed the stale duplicate objective-c block from the legacy tests/extraction/test_args_extraction.py monolithic file, fully superseded by tests/extraction/languages/test_objectivec.py.
  • Golden master fixtures re-blessed via 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 tests
  • tests/core_engine/test_detector.py -- extended ARGS_COUNT_FIXTURES["objective-c"] and added test_objectivec_args_body_lookalikes_excluded_by_signature_bound pinning the exact confirmed corpus shapes
  • Full pytest tests/ suite: 6844 passed
  • python tests/tools/audit_check.py: ruff/mypy/dead-key/ast-accuracy all clean
  • python tests/tools/crucible_check.py: full_precision + zero_dependency both PASS after re-blessing golden masters

🤖 Generated with Claude Code

…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]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit c2831f2 into main Aug 12, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the fix/objc-args-untyped-and-body-leak-1335 branch August 12, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

objective-c args extraction: untyped keyword-message params undercount to 0, and body content can leak into the count

1 participant