Skip to content

cpp: a call passing a lambda after its first argument is not a definition (Part of #5462) - #5684

Merged
squid-protocol merged 1 commit into
mainfrom
churn/5462-20261019T2149Z
Oct 19, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
churn/5462-20261019T2149Z

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Part of #5462.

What

C++ func_start counted a call as a function definition when the call passes a multi-line lambda after its first argument:

void outer(item_t& n) {
    walk(
        n,
        [&](const item_t& it) noexcept {
            const int v = get(it);
            if (keep(v)) {      // <- the old parameter block ran on to this `) {`

The parameter block's element [^)(] crossed ; and braces, so the match ran from walk( through the lambda body to a later ) {. The result was a phantom walk definition at the call line. The #2013 lambda shield only covered a lambda as the first argument.

Fix (cpp.py func_start item 7): a parameter list holds no ; and no brace other than a flat brace-init default (= {}, = {1, 2}). The new element \{[^(){};]*\} starts with a literal { that no other alternative can match, so it adds no backtracking.

Investigation of the #5462 C++ undercount (round 3)

After #5495 (template-qualified members) and #5572 (post-parameter tail), every named function in the internal files under study matches ctags. The rest of the count gap is not an engine miss:

  • lambdas: ctags emits each lambda as an __anon… function, and GitGalaxy does not count lambdas as functions (a counting convention, listed below);
  • a namespace-opening macro at column 0 (BEGIN_NS(x)), which ctags reports as a function (a ctags false positive).

The one engine defect found is the false positive fixed here.

Class: a call whose argument list holds a body

member status
lambda as first argument (f([&]() {) handled (#2013)
lambda after the first argument, a statement in its body before a later ) { fixed here
same, no statement before the next ) { (if (g(x)) {) fixed here
comment/newline between capture and body, mutable, -> T tail fixed here
GNU statement expression argument ({ ...; }) handled (test pins it)
brace-init default arg (= {}, = {1, 2}) in a real definition kept (test pins it)
member-initializer-list entry with a lambda handled (item 9 stops at {)

Evidence

  • New test tests/extraction/languages/test_cpp_lambda_argument_call.py: 6 call fixtures (5 fail on main, the statement-expression one is a guard), 6 definition fixtures that must keep matching, 3 ReDoS probes. The existing cpp suites (test_cpp*.py, 211 tests) pass.
  • Real engine scan of licensed ports (galaxyscope --db-only, before/after): only three definitions disappear, and all three are this shape: gzdoom hw_spritelight.cpp:252 BSPWalkCircle(...), eternity p_portal.cpp:609 P_BlockLinesIterator(...), odamex dlg_serverdetails.cpp:261 Bind(...). No real definition is lost.
  • Raw-regex sweep over every C/C++ file of gzdoom, odamex, doom3-bfg and eternity (71,181 matches before, 71,162 after). Every other change sits inside a string or comment that prism shields before func_start runs. Two examples: a "(" argument, and a ; inside a // comment in a parameter list. The real scan above confirms those definitions are kept.

Gates

  • pr_gates.py --fast: 6/6 pass (CI ruff 0.16.10, mypy 2.4.0).
  • pr_gates.py --ratchets: 8/8 pass (cics-spec, ports, port-surface, estate, fact-crosscheck, completeness, ground-truth, time).
  • crucible_check.py (no --update): full_precision PASS, zero_dependency PASS. The crucible corpus has no lambda-argument call of this shape, so there is no golden drift and no bless.
  • Tree-wide guards: 184 pass. Time ratchet on the new and changed C++ tests: 211 checked, 0 over.
  • audit_check.py: ruff, dead-key and ast-accuracy OK. With the local venv's mypy it reports 16 findings in detector.py, galaxyscope.py and cobol_to_java/*, none of them in this diff. That mypy differs from CI's; the CI-pinned mypy in --fast passes.

Sibling gaps (not in this PR)

  • C# func_start, same shape: Walk(\n node,\n (x) => {\n Use(x);\n if (Check(x)) { matches as a definition of Walk. It is a different language rule, so it is not done here. Java, JavaScript, Kotlin, Swift, C and Objective-C do not match the equivalent probe.
  • Lambda counting convention: ctags reports each lambda as an __anon… function and GitGalaxy does not. This is a convention decision, not a regex fix.

🤖 Generated with Claude Code

…tion (Part of #5462)

The func_start parameter block crossed `;` and braces, so `walk(n, [&](T& x) noexcept {`
ran through the lambda body to a later `) {` and counted a definition of `walk`.
A parameter list now holds no `;` and no brace except a flat brace-init default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Oct 19, 2026
@squid-protocol

Copy link
Copy Markdown
Owner Author

No description provided.

@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol enabled auto-merge (squash) October 19, 2026 22:15
@squid-protocol

Copy link
Copy Markdown
Owner Author

PR #5684 @ 354872e: 1 failed check(s)

== Call resolution (Level 2, vs pyan3) (failure) -- real
https://github.com/squid-protocol/gitgalaxy/actions/runs/39333246141/job/118336341128
repro: python tests/tools/pr_gates.py --fast
errors:
2026-10-19 22:12:40,410 [WARNING] [GalaxyScope] ┃ (--fail-on-malware cannot fire). Rule-based threats still run. ┃
2026-10-19 22:12:41,990 [WARNING] [GalaxyScope] ┃ (--fail-on-malware cannot fire). Rule-based threats still run. ┃
2026-10-19 22:12:42,334 [WARNING] [GalaxyScope] ┃ (--fail-on-malware cannot fire). Rule-based threats still run. ┃
2026-10-19 22:12:44,638 [WARNING] [GalaxyScope] ┃ (--fail-on-malware cannot fire). Rule-based threats still run. ┃
2026-10-19 22:12:47,073 [WARNING] [GalaxyScope] ┃ (--fail-on-malware cannot fire). Rule-based threats still run. ┃
2026-10-19 22:12:49,213 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:.AssertionError>
2026-10-19 22:12:49,214 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:
.AssertionError>
2026-10-19 22:12:49,214 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:.AssertionError>
2026-10-19 22:12:49,215 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:
.AssertionError>
2026-10-19 22:12:49,318 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:.AssertionError>
2026-10-19 22:12:49,322 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:
.AssertionError>
2026-10-19 22:12:49,841 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:.AssertionError>
2026-10-19 22:12:49,842 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:
.AssertionError>
2026-10-19 22:12:49,843 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:.AssertionError>
2026-10-19 22:12:49,844 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:
.AssertionError>
2026-10-19 22:12:49,844 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:.AssertionError>
2026-10-19 22:12:49,845 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:
.AssertionError>
2026-10-19 22:12:49,845 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:.AssertionError>
2026-10-19 22:12:49,895 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:
.AssertionError>
2026-10-19 22:12:52,351 [WARNING] [GalaxyScope] ┃ (--fail-on-malware cannot fire). Rule-based threats still run. ┃
2026-10-19 22:12:57,637 [WARNING] [GalaxyScope] ┃ (--fail-on-malware cannot fire). Rule-based threats still run. ┃
2026-10-19 22:12:57,829 [WARNING] [GalaxyScope] ┃ (--fail-on-malware cannot fire). Rule-based threats still run. ┃
2026-10-19 22:12:58,043 [WARNING] [GalaxyScope] ┃ (--fail-on-malware cannot fire). Rule-based threats still run. ┃
2026-10-19 22:12:58,233 [WARNING] [GalaxyScope] ┃ (--fail-on-malware cannot fire). Rule-based threats still run. ┃
2026-10-19 22:12:59,210 [INFO] [pyan.analyzer] New edge added for Use from to Name <Node ???:*.AssertionError>
... 68 more
log tail:
"overload_blind_precision_pct": 99.7
},
"recall_all_kinds_pct": 76.4,
"resolution_recall_pct": 97.7,
"named_pyan_edges": 1748,
"pyan_edges": 3592,
"wrong_examples": [
"fastapi: fastapi/routing.py:app -> fastapi/exceptions.py:45 (pyan3: fastapi/exceptions.py:213)",
"fastapi: tests/test_arbitrary_types.py:test_typeadapter -> tests/test_arbitrary_types.py:20 (pyan3: tests/test_arbitrary_types.py:59)"
],
"external_examples": [],
"reference_version": "2.9.0",
"lang": "python"
}
}
| language | reference | confident precision | ambiguous precision | recall | resolution recall |
|---|---|---|---|---|---|
| python | pyan3 | 99.9% (1829 judged) | 60.0% | 50.9% | 97.7% |
decorator edges (not gated): precision 100.0% (575 judged); recall with decorators 66.9%
reference edges (not gated): precision 99.7% (345 judged); recall, all kinds 76.4%
call_graph_resolution: WARNING -- pyan3 2.9.0 is not the pinned 2.8.1; numbers are not comparable to the baseline
call_graph_resolution: REGRESSION
python: recall_pct 51.7 -> 50.9
##[error]Process completed with exit code 1.
Post job cleanup.
[command]/usr/bin/git version
git version 2.55.0
Temporarily overriding HOME='/home/runner/work/_temp/9ba76e18-53fa-44ab-bfee-105ed035b540' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
[command]/usr/bin/git config --global --add safe.directory /home/runner/work/gitgalaxy/gitgalaxy/gitgalaxy
Removing SSH command configuration
[command]/usr/bin/git config --local --name-only --get-regexp core.sshCommand
[command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
Removing HTTP extra header
[command]/usr/bin/git config --local --name-only --get-regexp http.https://github.com/.extraheader
[command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http.https://github.com/.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
Removing includeIf entries pointing to credentials config files
[command]/usr/bin/git config --local --name-only --get-regexp ^includeIf.gitdir:
[command]/usr/bin/git submodule foreach --recursive git config --local --show-origin --name-only --get-regexp remote.origin.url
Cleaning up orphan processes

@squid-protocol squid-protocol added shepherd:needs-fix Bot: a real failure on this head; see the digest comment. Guide: docs/ci.md shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md and removed shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md labels Oct 19, 2026
@squid-protocol

Copy link
Copy Markdown
Owner Author

No description provided.

Comment on lines +24 to +29
"void outer(item_t& n) {\n"
" walk(\n"
" n,\n"
" [&](const item_t& it) noexcept {\n"
" const int v = get(it);\n"
" if (keep(v)) {\n",
@squid-protocol
squid-protocol merged commit dd538ee into main Oct 19, 2026
102 of 104 checks passed
@squid-protocol
squid-protocol deleted the churn/5462-20261019T2149Z branch October 19, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md shepherd:needs-fix Bot: a real failure on this head; see the digest comment. Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants