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
Fix union assertions #8324
Fix union assertions #8324
Conversation
The shepherd issue seems to be present upstream: https://psalm.dev/r/e0bee4534f |
I found these snippets: https://psalm.dev/r/e0bee4534f<?php
/**
* Asserts that two variables are the same.
*
* @param object $actual
* @psalm-assert-if-true (a|b|c) $actual
*/
function assertSame($actual) : void {}
class a {}
class b {}
class c {}
/** @var object */
$actual = new c;
if (assertSame($actual)) {
/** @psalm-trace $actual */;
}
|
Mm actually even with the additional int range handling in intersections we're still missing intersection logic for keyed arrays, I feel like I'm duplicating code already present in the assertion reconciler, once I fix the last unit case I'd still prefer to get this merged, but eventually we should be using the same code used in the assertion reconciler to perform intersections, differences&so on... |
All done! |
Thanks! |
Fixes #8322, #8319 and a few other bugs introduced by #8077, by explicitly running the intersection logic only on IsIdentical assertions (due to the semantics of Type::intersectUnionTypes wasn't sure if we should run it on IsType assertions), and removing the custom intersection/equality logic which broke other stuff in the code.