psalm icon indicating copy to clipboard operation
psalm copied to clipboard

Unset on shape with literal variable key not inferring exact shape

Open danog opened this issue 2 years ago • 1 comments

https://psalm.dev/r/1f834d0ed7, already fixing in my immutable PR

danog avatar Sep 21 '22 09:09 danog

I found these snippets:

https://psalm.dev/r/1f834d0ed7
<?php
$a = 1;
$test = [0, 1];
unset($test[$a]);
/** @psalm-trace $test **/

$test2 = [0, 1];
unset($test2[1]);
/** @psalm-trace $test2 */
Psalm output (using commit 028ac7f):

INFO: Trace - 7:1 - $test: array<0|1, 0|1>

INFO: Trace - 9:27 - $test2: array{0}

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

Yup, this is fixed :)

orklah avatar Oct 22 '22 11:10 orklah