-
Notifications
You must be signed in to change notification settings - Fork 510
Fix MixedType->equals(ErrorType) #3934
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
base: 2.1.x
Are you sure you want to change the base?
Conversation
|
This pull request has been marked as ready for review. |
👍 I suppose this improves the weird cases I had before too, where error is accepted as a mixed or at least something like that 😊 |
src/Analyser/MutatingScope.php
Outdated
@@ -4489,7 +4489,7 @@ public function addTypeToExpression(Expr $expr, Type $type): self | |||
|
|||
if ($originalExprType->equals($nativeType)) { | |||
$newType = TypeCombinator::intersect($type, $originalExprType); | |||
if ($newType->isConstantScalarValue()->yes() && $newType->equals($originalExprType)) { | |||
if ($newType->isObject()->no() && $newType->equals($originalExprType)) { |
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.
Will look into whether we can get rid of the isObject() check here today
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.
ok, I looked into it. I think we cannot drop the $newType->isObject()->no()
check here, because Objects will be considered equal by ObjectType->equals()
even though they have slight differences which are important when narrowing, e.g.
new Foo()
in local-scope vs. Foo
typed variable (implicit Final)
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.
most conservative move would be to leave it $newType->isConstantScalarValue()->yes()
until we get a slow case which benefits from the change and only fix MixedType->equals(ErrorType)
for now
868ed2e
to
65df00a
Compare
just reduced it to the actual bugfix. |
refs #3933 (comment)