Skip to content

Do not assign in the if condition of ParserRunner::parse() - #7135

Merged
ondrejmirtes merged 1 commit into
2.3.xfrom
parser-runner-no-assignment-in-if
Nov 24, 2026
Merged

ondrejmirtes merged 1 commit into
2.3.xfrom
parser-runner-no-assignment-in-if

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

Since c9f7d8928 ("Turbo: native Php7 parser"), the Turbo Extension Lint check (make lint-turbo, clang-tidy 21) fails on 2.3.x. It's red on dfdb69d12, 061d99163 and HEAD 29163709a:

src/parser/ParserRunner.cpp:1275:46: error: an assignment within an 'if' condition is bug-prone [bugprone-assignment-in-if-condition,-warnings-as-errors]
  • Green baseline: 7e86b9ecf (Turbo Extension Lint passed).
  • First bad commit: c9f7d8928. It was pushed together with dfdb69d12, the first commit whose lint run failed, and git blame puts line 1275 in it.

Fix. The parser tables are now prepared in the declaration, and only for a string input as before, so the if only tests the result. Nothing else changes. Per turbo-ext/CLAUDE.md the finding is fixed rather than silenced or excluded.

Verification (local, clang-tidy 21 as pinned):

  • Before the fix, clang-tidy-21 -p . src/parser/ParserRunner.cpp reports the CI error. After it, make lint-turbo over every source exits 0.
  • Strict build (-Werror warning flags) and make build-turbo pass.
  • tests/smoke.php: ALL OK. tests/signature-parity.php: OK (18526 members compared).
  • tests/parser-corpus.php: 19032 files, 0 failed. tests/parser-upstream-corpus.php: 524 php-parser cases, 0 failed.
  • Full paratest suite with the extension loaded: 23961 tests OK.

Only the native extension changes, not PHP code shipped in the PHAR, so the downgraded PHAR's PHP 7.4 compatibility is unaffected.

clang-tidy's bugprone-assignment-in-if-condition fails Turbo Extension Lint
since the native Php7 parser. The tables are still prepared only for a
string input.
@ondrejmirtes
ondrejmirtes merged commit 85bbcdf into 2.3.x Nov 24, 2026
382 checks passed
@ondrejmirtes
ondrejmirtes deleted the parser-runner-no-assignment-in-if branch November 24, 2026 08:43
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.

1 participant