Skip to content
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

Merged
merged 13 commits into from Jul 28, 2022
Merged

Fix union assertions #8324

merged 13 commits into from Jul 28, 2022

Conversation

danog
Copy link
Collaborator

@danog danog commented Jul 27, 2022

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.

@danog
Copy link
Collaborator Author

danog commented Jul 27, 2022

The shepherd issue seems to be present upstream: https://psalm.dev/r/e0bee4534f

@psalm-github-bot
Copy link

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 */;
}
Psalm output (using commit 63b389f):

INFO: UnusedParam - 8:41 - Param $actual is never referenced in this method

INFO: Trace - 15:28 - $actual: a

@danog
Copy link
Collaborator Author

danog commented Jul 27, 2022

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...

@danog
Copy link
Collaborator Author

danog commented Jul 28, 2022

All done!

@danog danog requested a review from orklah July 28, 2022 10:08
@orklah orklah added the release:fix The PR will be included in 'Fixes' section of the release notes label Jul 28, 2022
@orklah orklah merged commit 7c4228f into vimeo:master Jul 28, 2022
@orklah
Copy link
Collaborator

orklah commented Jul 28, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix The PR will be included in 'Fixes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants