Fix cpp func_start false positive on lambda constructor arguments (closes #2013) - #2025
Merged
Conversation
…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>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2013. A lambda passed as a constructor argument or member-initializer-list
entry (
m_draggingState([this]() { ... }),inpowertoys/FancyZones.cpp,std::thread([...]() { ... }).detach();inpowertoys/main.cpp) was misread bycpp's
func_startregex as a real function definition named after the lambda'starget. The regex correctly balances the lambda's own parens, but nothing after
the closing
)distinguishes a real function's parameter list from a callpassing 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 lambdacapture-list does (
[this],[=],[&x],[]). The sole exception, aparameter-level
[[attribute]], always has a literal double bracket, which thelookahead still allows through.
Test plan
[[attribute]]parameters, normal params, the two real false positives)tests/core_engine/test_detector.pyruff_audit.py --ci/mypy_audit.py --ci— no new findingszero 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/powertoysdirectory-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