-
Notifications
You must be signed in to change notification settings - Fork 650
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: Fix parsing of invalid intersection types #8385
base: master
Are you sure you want to change the base?
Conversation
Returns `TNever` for an intersection of 2 non-overlapping named classes instead of throwing an exception. Will raise a new `InvalidIntersectionType` in the case that this is detected. Psalm will now also raise a parse error instead of throwing if it cannot deduce the resolved intersection type. Resolves vimeo#8333
Well, the question is, does If it can happen, it would definitely mean a InvalidIntersectionType should be emitted and your change would not do that. If it can't happen then yeah, we should try to keep consistency. |
All fixed! |
Actually nevermind, it seems like there's a bug in the InArray assertion reconciler |
Union $type_1, | ||
Union $type_2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this BC break here? This is a part of our API surface, so the earliest it can change is in Psalm 6.
This fixes #8333 properly, replacing #8384.
I feel that we need to be consistent with the return type of
Type::intersectUnionTypes
: if there is no possible intersection between the types, return null, otherwise return a Union with the types.The previous PR incorrectly returned TNever only for certain invalid intersections: if we really want to go with that approach, then let's always return either a Union or a Union(TNever), and never
null
(but I would personally leave it as it is right now, as it's easier to tell if there's no intersection between the types this way).