Skip to content

Fix cpp func_start false positive on lambda constructor arguments (closes #2013) - #2025

Merged
squid-protocol merged 2 commits into
mainfrom
chore/cpp-precision-round2
Aug 21, 2026
Merged

Fix cpp func_start false positive on lambda constructor arguments (closes #2013)#2025
squid-protocol merged 2 commits into
mainfrom
chore/cpp-precision-round2

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Fixes #2013. A lambda passed as a constructor argument or member-initializer-list
entry (m_draggingState([this]() { ... }), in powertoys/FancyZones.cpp,
std::thread([...]() { ... }).detach(); in powertoys/main.cpp) was misread by
cpp's func_start regex as a real function definition named after the lambda's
target. The regex correctly balances the lambda's own parens, but nothing after
the closing ) distinguishes a real function's parameter list from a call
passing a lambda — the next non-whitespace token legitimately is { either way
(a real function body, or, for the initializer-list case, the enclosing
constructor's own body).

Fixed with a negative lookahead on the parameter-list group: a real C++
parameter list can never syntactically start with a bare [ — only a lambda
capture-list does ([this], [=], [&x], []). The sole exception, a
parameter-level [[attribute]], always has a literal double bracket, which the
lookahead still allows through.

Test plan

  • 11 hand-built regression cases (forward-declaration-adjacent shapes,
    [[attribute]] parameters, normal params, the two real false positives)
  • Full cpp extraction gauntlet (122 tests) + tests/core_engine/test_detector.py
  • ruff_audit.py --ci / mypy_audit.py --ci — no new findings
  • Full corpus scan: raw func_start match count drops by exactly 2 (1483 → 1481),
    zero unintended side effects anywhere else in the ~80-repo corpus
  • crucible_check.py (full-precision + zero-dependency) — real, reviewed diff
    (both false positives disappearing plus their obvious downstream ripple:
    structural magnitude/topology coordinates recalculating, cpp/powertoys
    directory-group risk averages shifting, global cpp impact/documentation
    aggregates moving accordingly — no mismatch touched any other language or
    file), both golden masters re-blessed and now passing cleanly

🤖 Generated with Claude Code

squid-protocol and others added 2 commits August 21, 2026 12:10
…oses #2013)

A lambda passed as a constructor argument or member-initializer-list entry
(`m_draggingState([this]() { ... }),`, `std::thread([...]() { ... }).detach();`)
was misread as a real function definition -- the regex correctly balances the
lambda's own parens, but nothing after the closing paren distinguishes "this
was a real function's parameter list" from "this was a call passing a lambda",
since the very next non-whitespace token legitimately is `{` either way (a real
function body, or, for the initializer-list case, the enclosing constructor's
own body).

Fixed with a negative lookahead: a real C++ parameter list can never
syntactically start with a bare `[` -- only a lambda capture-list does that
(the sole exception, a parameter-level `[[attribute]]`, always has a literal
DOUBLE bracket, which the lookahead still allows through).

Verified via 11 hand-built regression cases, the full 122-test cpp extraction
gauntlet, and a full corpus scan (raw func_start match count drops by exactly
2, precisely the two known false positives, zero side effects elsewhere).
crucible_check.py / golden master re-bless still pending in this commit --
follow-up commit will handle that once verified.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
crucible_check.py confirmed clean on both full-precision and
zero-dependency modes. All 29/9 mismatches (full-precision/zero-dependency
respectively) traced to powertoys/FancyZones.cpp and powertoys/main.cpp
losing their two false-positive functions (m_draggingState, std::thread)
and the expected downstream ripple: per-file structural magnitude/
topological coordinates recalculating, cpp/powertoys directory-group risk
averages shifting, and the global cpp impact/documentation aggregates
moving accordingly. No mismatch touched any other language or file.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@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 aebb0e0 into main Aug 21, 2026
28 of 29 checks passed
@squid-protocol
squid-protocol deleted the chore/cpp-precision-round2 branch August 21, 2026 16:24
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.

cpp func_start: False positives from lambdas in constructors and member-initializer-lists

1 participant