New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReferenceConstraintViolation with non-empty-literal-string in array #7095
Labels
Comments
I found these snippets: https://psalm.dev/r/2756501f64<?php
/**
* @param "a"|"b"|"c" $a
* @param array<non-empty-string, true> $b
*/
function foo(string $a, array &$b): void
{
/** @psalm-trace $baz */
$baz = "bar $a";
$b[$baz] = true;
}
$b = [];
foo("a", $b);
https://psalm.dev/r/f8845a750d<?php
/**
* @param non-empty-string $bar
*/
function foo(string $bar): string
{
return $bar;
}
/** @var "bar"|"baz" */
$bar = "bar";
/** @psalm-trace $baz */
$baz = "foo$bar";
foo($baz);
https://psalm.dev/r/c9ad19355c<?php
/**
* @param "a"|"b"|"c" $a
* @param non-empty-string $b
*/
function foo(string $a, string &$b): void
{
/** @psalm-trace $baz */
$baz = "bar $a";
$b = $baz;
}
$b = "b";
foo("a", $b);
|
I'm not familiar with Psalm internals (and I've run out of time today), but it looks like |
AndrolGenhald
added a commit
to AndrolGenhald/psalm
that referenced
this issue
Dec 8, 2021
orklah
added a commit
that referenced
this issue
Dec 8, 2021
Fix non-empty-literal-string to behave as subtype of non-empty-string (fixes #7095).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
non-empty-literal-string
should be a subtype ofnon-empty-string
, but it still results in aReferenceConstraintViolation
: https://psalm.dev/r/2756501f64This seems specific to
ReferenceConstraintViolation
, it acts correctly when anon-empty-literal-string
is used as an argument that requiresnon-empty-string
: https://psalm.dev/r/f8845a750dIn fact, it seems to be something about using it in an array, just having it as the parameter itself works fine: https://psalm.dev/r/c9ad19355c
The text was updated successfully, but these errors were encountered: