-
Notifications
You must be signed in to change notification settings - Fork 655
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
property assignment bug with union and int ranges #10826
Comments
I found these snippets: https://psalm.dev/r/808fd263bd<?php
/**
* @return -1|positive-int
*/
function getInt():int {
if (rand(0,1)) {
return 234;
}
return -1;
}
class C {
/** @var positive-int|null */
private $p;
function doFoo():void {
$i = getInt();
if ($i === -1) {
$i = null;
}
$this->p = $i;
}
}
|
Simplified: https://psalm.dev/r/4998359b55 The root issue seems to be |
I found these snippets: https://psalm.dev/r/4998359b55<?php
/**
* @return -1|positive-int
*/
function foo(): int { return random_int(0, 1) ? -1 : 1; }
$a = foo();
/** @psalm-trace $a */
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this should not error https://psalm.dev/r/808fd263bd
The text was updated successfully, but these errors were encountered: