Repository navigation
Description
What
While investigating #1314's objc func_start precision fix (PR #1328) and its bodyless-@interface-declaration follow-up (PR #1332), args-count verification against language-crucible/data/objective-c/worldwideweb surfaced two related, unfixed gaps in objc's args extraction. Both are real, confirmed-against-corpus GitGalaxy defects (not measurement-tool artifacts).
1. Untyped keyword-message parameters undercount to 0. GitGalaxy's args regex (language_standards.py's objc "args" rule, branch 1) requires a (Type) cast between each label: and its parameter name. Older, still-valid Objective-C style omits the type (defaults to id) -- e.g. - back:sender { ... }, - help:sender, + setManager:aManager. None of these are recognized as having any parameters at all (args=0 instead of 1+). Confirmed via HyperManager.m: back, help, save, open, traceOn, searchRTF, and roughly 15 others in that one file alone.
2. When a method's own signature doesn't match ANY args branch (case 1 above, or a genuinely zero-arg method with no colon at all), args extraction falls through past the real signature and matches the first C-style-shaped call/statement found later in the method's own body -- because args_pattern.search(block) searches the whole sliced function body, not just the signature line. Confirmed concretely:
Anchor.m's- free { if (Address) free(Address); ... }(zero-arg, no colon) measuresargs=1, borrowed from thefree(Address);call inside its own body.HyperManager.m's- closeOthers:sender { ... printf("...", w); ... }(1 real untyped param) measuresargs=2, borrowed from the unrelatedprintf(...)call's 2 comma-separated arguments.
This is the same architectural shape as #1221's "Invocation Shield" (bare call statements false-positive-matching as function signatures), but for objc's args regex specifically rather than func_start -- #1221's fix didn't cover this pillar/language combination.
Why this needs care, not a quick regex patch
Simply making the (Type) annotation optional in branch 1 would fix (1) and most instances of (2), but risks a new false positive: a ternary expression later in a method's body (cond ? a : b) would then also match the loosened "optional-parens colon segment" shape, since parens would no longer be required to distinguish a real keyword-message parameter from an unrelated label : value shape. This exact corpus (1990s NeXTSTEP-era C) uses ternaries. Any fix needs either:
- A proper "Invocation Shield" for objc's args regex (bound the search to the actual signature span, not the whole body), or
- Careful adversarial testing (per
how_to_add_a_language.md's methodology) against ternary/nested-conditional shapes before loosening branch 1.
Suggested next step
Start with tests/extraction/languages/test_objectivec.py's args gauntlet + tests/core_engine/test_detector.py's _count_colon_selector_segments unit tests as the adversarial-case baseline. Consider anchoring the args search to a bounded prefix of block (up to the first real terminator) rather than the whole body, which would structurally prevent case (2) regardless of case (1)'s outcome.
Activity
fix(objc): recognize untyped keyword-message args, stop body leak int…
fix(c): bound args search to the signature, not the whole body (#1672)
fix(core-engine): args counts declared parameters, not call sites (ob…
fix(core-engine): args counts declared parameters, not call sites (ob…
fix(core-engine): args counts declared parameters, not call sites (ob…