psalm icon indicating copy to clipboard operation
psalm copied to clipboard

Psalm forgets about unset assertion outside of if

Open danog opened this issue 2 years ago • 1 comments

https://psalm.dev/r/2a90fda384

danog avatar Sep 28 '22 09:09 danog

I found these snippets:

https://psalm.dev/r/2a90fda384
<?php
/** @var non-empty-array<string|int, int> */
$test = ['test' => 0];
/** @var string|int */
$k = 'test';
if (isset($test[$k])) {
    unset($test[$k]);
	/** @psalm-trace $test */
}

/** @psalm-trace $test */
Psalm output (using commit 028ac7f):

INFO: Trace - 8:0 - $test: array<int|string, int>

INFO: Trace - 11:26 - $test: non-empty-array<int|string, int>

psalm-github-bot[bot] avatar Sep 28 '22 09:09 psalm-github-bot[bot]