Skip to content

Report a dead || operand next to other values of the same variable - #14821

Merged
orklah merged 1 commit into
vimeo:masterfrom
orklah:paradox-or-operand
Nov 24, 2026
Merged

orklah merged 1 commit into
vimeo:masterfrom
orklah:paradox-or-operand

Conversation

@orklah

@orklah orklah commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Psalm misses ParadoxicalCondition on a dead operand of an || when the other operands test the same variable.

Before

<?php
function f(string $o): string {
    if ("term_id" === $o) {
        return "a";
    }

    if ("id" === $o || "term_id" === $o) { // no issue
        return "b";
    }

    return "c";
}

After

    if ("id" === $o || "term_id" === $o) { // ParadoxicalCondition on `"term_id" === $o`

Fixes #14791

`if ($o === 'a') return; if ($o === 'b' || $o === 'a')` no longer reported the
dead `$o === 'a'`: the operand check skipped an || whose operands all test one
variable. That pattern is written dead code; the in_array() of vimeo#5712 is not an
||, so it stays unreported. orOfAValueAnEarlierConditionExcludedAndAnotherIsNotParadoxical
asserted the dead operand was fine and becomes the invalid case
deadLeftOperandNextToAnotherValueOfTheSameVariableIsParadoxical.

Fixes vimeo#14791

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@orklah orklah added the release:fix The PR will be included in 'Fixes' section of the release notes label Nov 24, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T12:00:45.421901Z fbe4e63 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fbe4e63a03

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

✅ Performance: unchanged · Types: increased

Project Memory (MB) Wall (s) Issues Weighted (types) Taint Dead code
✅ laravel 1 762 97.6 25 785 53 052 743 0
✅ symfony 3 649 286.3 $\color{gray}{\textsf{+4.3\%}}$ 51 753 100 487 1 585 0
✅ doctrine-orm 384 21.7 $\color{gray}{\textsf{-2.3\%}}$ 3 453 6 194 0 0
✅ psl 622 23.6 $\color{gray}{\textsf{-5.3\%}}$ 1 396 5 647 1 0
✅ phpunit 431 14.5 $\color{gray}{\textsf{+2.5\%}}$ 1 590 2 403 18 0
✅ php-parser 228 9.2 $\color{gray}{\textsf{+0.2\%}}$ 17 113 21 177 0 0
✅ tempest 893 26.2 $\color{gray}{\textsf{+2.0\%}}$ 5 093 10 547 275 0
✅ amphp-amp 48 1.6 $\color{gray}{\textsf{+1.9\%}}$ 31 53 0 0
✅ webmozarts-assert 275 4.8 $\color{gray}{\textsf{+1.9\%}}$ 576 2 720 0 0
✅ guzzle-promises 46 1.8 $\color{gray}{\textsf{+1.7\%}}$ 155 433 2 0
✅ monolog 135 6.3 $\color{gray}{\textsf{+1.6\%}}$ 918 2 491 11 0
✅ drupal 4 801 277.3 $\color{gray}{\textsf{-2.1\%}}$ 97 829 169 274 575 0
✅ wordpress 2 029 206.5 $\color{gray}{\textsf{-0.6\%}}$ 143 503 $\color{red}{\textsf{+1}}$ $\color{gray}{\textsf{-0}}$ 678 368 $\color{red}{\textsf{+10}}$ 505 1
Total 15 302 977.3 $\color{gray}{\textsf{+0.4\%}}$ 349 195 $\color{red}{\textsf{+1}}$ $\color{gray}{\textsf{-0}}$ 1 052 846 $\color{red}{\textsf{+10}}$ 3 715 1
How to read this table
  • Memory: Psalm's own peak figure, threads=1. More than +5 % fails, unless the PR changes composer.json.
  • Wall: base and head run on the same runner; ±10 % is noise. Above +10 % warns, never fails. re-run: a reversed second run was taken and the faster kept.
  • Issues: head count over all categories, then $\color{red}{\textsf{+added}}$ $\color{green}{\textsf{-removed}}$ against base.
  • Weighted (types): type issues weighted by error level (levels 1–8 as is, always-errors 10, strictness checks 1). Taint and dead-code issues are not weighed. The projects' own code is pinned and their dependencies resolve identically for base and head, so a change means Psalm reports more, fewer or differently serious issues. A rise is not necessarily a regression.
  • Taint: head count of Tainted* issues, then $\color{orange}{\textsf{+added}}$ $\color{orange}{\textsf{-removed}}$ against base. Both are orange as either direction needs review: more can be new detection or false positives, fewer can be fixed false positives or lost detection.
  • Dead code: head count of unused-code issues, shown only when a run reported some (findUnusedCode). More is red, fewer is green.
  • Total: sum over the projects compared on both sides. Its wall time warns above +5 % (±5 % is noise); the other thresholds apply per project.
  • Profiling: when both sides support it, the measured runs use --debug-performance=PATH for the hot-files block, which adds the same small CPU and memory cost to both sides.
  • Colors: $\color{red}{\textsf{red}}$ past a fail or warn threshold (or more issues), $\color{green}{\textsf{green}}$ an improvement past noise (or fewer issues), $\color{orange}{\textsf{orange}}$ needs review, $\color{gray}{\textsf{gray}}$ noise.
  • Performance: regressed if a head run crashed or timed out or a memory or wall delta is red, else improved if one is green, else unchanged. Its icon is the check result: ❌ fail · ⚠️ warn · ✅ pass; the icon next to each project is that project's result, 💥 = not comparable: base crashed or timed out (counts as ⚠️).
  • Types (heading): direction of the total weighted change, increased · decreased · unchanged. Taint and Dead code (heading): added and removed counts, present only when non-zero. Informational, never fails the check.
✅ wordpress: issues +1 −0

Memory 2 029 → 2 029 MB (<0.1 %) · Wall 207.7 → 206.5 s (−0.6 %)

Weighted 678 358 → 678 368 (+10, <0.01 %): always +1

Issue type added removed
ParadoxicalCondition 1 0

Added (1)

  • src/wp-includes/class-wp-term-query.php:936 ParadoxicalCondition (error): Condition ($_orderby is string(term_id)) contradicts a previously-established condition ($_orderby is not string(term_id))

head fbe4e63 · base 85636ae (merge-base) · workflow run

@orklah

orklah commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Why the exemption goes:

That skipped case is written dead code (WordPress class-wp-term-query.php:936, the only perf-report delta), so this PR drops the skip and turns that test into the invalid case deadLeftOperandNextToAnotherValueOfTheSameVariableIsParadoxical.

Unchanged:

@orklah
orklah merged commit fee675f into vimeo:master Nov 24, 2026
75 checks passed
@orklah
orklah deleted the paradox-or-operand branch November 24, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:fix The PR will be included in 'Fixes' section of the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missed ParadoxicalCondition on an impossible operand of ||

1 participant