Skip deep expression when root expression changes while scope generalization#4390
Skip deep expression when root expression changes while scope generalization#4390ondrejmirtes merged 6 commits intophpstan:2.1.xfrom
Conversation
|
from my POV the problem in the reported types is -non-empty-array<int<0, 9>, non-empty-array<0|1, string>>
+non-empty-array<int<0, 9>, non-empty-array<int<0, 9>, string>>so thats why my idea was that in the deeper nested key-type no generalization happend and thats what missing. IMO when only one of the involved scopes contains a general or constant array, we don't do deep generalization (recursive) in
(but I am looking at this stuff for the first time... I might be wrong :)) |
|
Yeah, it's possible the problem is with generalization and not merging scopes, I was just debugging this in my head, not in code 😂 |
|
Yeah, that's basically what I'm talking about in #4372 (comment), this is what I imagine the problem would look like. After updating I think that actually "updating" after assignment works fine, but merging scopes probably doesn't handle this. |
|
I finally understood what you are trying to tell me :). |
|
This pull request has been marked as ready for review. |
84ace80 to
a63e8c6
Compare
|
I'm also trying to figure out the other regression. |
|
thank you! |
|
I don't know yet, will think about it more :) Thank you. |

implement the idea described in #4372 (comment)
it does not fix the problem we see the wrong types we see from https://phpstan.org/r/16197474-84cb-43ad-b983-ad78371fba02 though