Skip to content

Truthy check fails to refine type #1014

@muglug

Description

@muglug
$s = rand(0, 1) ? 0 : 1;

if ($s) {
  $s = 3;
}

if ($s === 1) {}

Expected: Strict comparison using === between 0|3 and 1 will always evaluate to false.
Actual: No issue

Fixed by making the comparison explicit:

$s = rand(0, 1) ? 0 : 1;

if ($s === 1) {
  $s = 3;
}

if ($s === 1) {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions