psalm icon indicating copy to clipboard operation
psalm copied to clipboard

Literal nested string union not being inferred correctly

Open danog opened this issue 2 years ago • 1 comments

https://psalm.dev/r/95c684461e

danog avatar Sep 16 '22 16:09 danog

I found these snippets:

https://psalm.dev/r/95c684461e
<?php

/** @var 'a'|'b'|'c' */
$a = "a";
$b = 'test_'.$a;
$c = "test_$a";

/** @psalm-trace $b */;
/** @psalm-trace $c */;
Psalm output (using commit d957ff2):

INFO: Trace - 8:23 - $b: 'test_a'|'test_b'|'test_c'

INFO: Trace - 9:23 - $c: non-empty-literal-string

INFO: UnusedVariable - 4:1 - $a is never referenced or the value is not used

INFO: UnusedVariable - 5:1 - $b is never referenced or the value is not used

INFO: UnusedVariable - 6:1 - $c is never referenced or the value is not used

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