psalm icon indicating copy to clipboard operation
psalm copied to clipboard

Psalm remembers previous array key assertion even if array is replaced

Open danog opened this issue 3 years ago • 3 comments

Thought it was a bug in my immutable refactoring, turns out it's also present upstream: https://psalm.dev/r/05f744e632

danog avatar Jul 26 '22 10:07 danog

I found these snippets:

https://psalm.dev/r/05f744e632
<?php

$dummy = ['test' => ''];

$a = ['test' => null];

if ($a['test'] === null) {
    $a = $dummy;
}
$var = $a['test'];
/** @psalm-trace $var */;
Psalm output (using commit 4b2935f):

INFO: Trace - 11:25 - $var: null

INFO: UnusedVariable - 3:1 - $dummy is never referenced or the value is not used

INFO: UnusedVariable - 8:5 - $a is never referenced or the value is not used

INFO: UnusedVariable - 10:1 - $var is never referenced or the value is not used

psalm-github-bot[bot] avatar Jul 26 '22 10:07 psalm-github-bot[bot]

Broken by https://github.com/vimeo/psalm/commit/d7d9ddc653b7d292970baa9f6de2bf43b7db57ef#

danog avatar Jul 26 '22 11:07 danog

Pinging @muglug :)

danog avatar Jul 26 '22 11:07 danog