Repository navigation
cpp: a call passing a lambda after its first argument is not a definition (Part of #5462) - #5684
Conversation
…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]>
|
No description provided. |
|
PR #5684 @ 354872e: 1 failed check(s) == Call resolution (Level 2, vs pyan3) (failure) -- real |
|
No description provided. |
| "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", |
Part of #5462.
What
C++
func_startcounted a call as a function definition when the call passes a multi-line lambda after its first argument:The parameter block's element
[^)(]crossed;and braces, so the match ran fromwalk(through the lambda body to a later) {. The result was a phantomwalkdefinition at the call line. The #2013 lambda shield only covered a lambda as the first argument.Fix (
cpp.pyfunc_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:
__anon…function, and GitGalaxy does not count lambdas as functions (a counting convention, listed below);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
f([&]() {)) {) {(if (g(x)) {)mutable,-> Ttail({ ...; })= {},= {1, 2}) in a real definition{)Evidence
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.galaxyscope --db-only, before/after): only three definitions disappear, and all three are this shape: gzdoomhw_spritelight.cpp:252 BSPWalkCircle(...), eternityp_portal.cpp:609 P_BlockLinesIterator(...), odamexdlg_serverdetails.cpp:261 Bind(...). No real definition is lost.func_startruns. 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.audit_check.py: ruff, dead-key and ast-accuracy OK. With the local venv's mypy it reports 16 findings indetector.py,galaxyscope.pyandcobol_to_java/*, none of them in this diff. That mypy differs from CI's; the CI-pinned mypy in--fastpasses.Sibling gaps (not in this PR)
func_start, same shape:Walk(\n node,\n (x) => {\n Use(x);\n if (Check(x)) {matches as a definition ofWalk. 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.__anon…function and GitGalaxy does not. This is a convention decision, not a regex fix.🤖 Generated with Claude Code