-
Notifications
You must be signed in to change notification settings - Fork 479
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
Do not merge BenevolentUnionType
with UnionType
#2058
Do not merge BenevolentUnionType
with UnionType
#2058
Conversation
175fd36
to
7c3ff7b
Compare
OK close, better than I thought. I guess I deleted too much and am loosing the benevolent template object.. |
You should measure whether these changes have a perf impact |
Since |
Good question, I'm not sure if it should be tbh. If we explicitly want a union, shouldn't it be non-benevolent? 🤔 I guess what I'm saying is, are we expecting this to be simplified if we call |
7c3ff7b
to
ff51d9f
Compare
c2c716e
to
8c77918
Compare
This pull request has been marked as ready for review. |
3515799
to
3e7fff1
Compare
ecb2fc4
to
23bee84
Compare
I'm struggling a bit with this one. What is your thinking behind this PR? I see that it fixes a bunch of issues, but to me it looks like it's just a matter of luck, not an intention (please take no offense :)). What's a typical situation that this PR improves/fixes? Also, I think we need some more tests around this. Let's say for example we have
|
The main intention behind this is that I believe, and I think the linked issues confirm it, that union with a benevolent union should not suddenly get rid of the benevolence. E.g. https://phpstan.org/r/498cd1d0-4568-4cbf-8b0b-11ed722552e8 Calling But it's basically what you suggested at phpstan/phpstan#8268 (comment) (which I just found later via issue bot). |
23bee84
to
322a89a
Compare
Added the test cases for union with
that looks OK to me 😊 |
I'd argue that Another idea for a test - if we have Also we can test what happens with Also |
Ok, added your mentioned cases again, the result is a bit different, I got
so most likely there's still work needed / it can be improved? I pushed them in this state, but need to think about this another time. Such benevolent cases are still hard for me to think through properly |
c99a035
to
6e10519
Compare
https://phpstan.org/r/9be20c04-429f-4dc0-b245-9d23628ae2db Both
Technically, it should be Because if it's transformed into
|
c9865e5
to
3251d3d
Compare
Sorry, here's the proper link: phpstan/phpstan#7423 I also fixed it in my previous message. |
yeah and why do you mean this PR does not fix it? the bot message there is unrelated. but in https://github.com/phpstan/phpstan-src/actions/runs/3910108845 I can see no errors for PHP 8+ because the type should be correct now? and that is also checked via regression test here. |
This comment was marked as off-topic.
This comment was marked as off-topic.
f6fb159
to
aad632d
Compare
Did we come to a conclusion about this one? :) I rebased it on 1.10.x in the meantime. Thought the behavior change might be better there. In case it gets merged. So far it still makes sense to me |
70d77ae
to
9d76dfa
Compare
9d76dfa
to
a5de12b
Compare
Going to rebase this one tomorrow morning. Is there anything else I can do here? This still makes sense to me :) |
@herndlm I have some issues with it. For example I've seen a type For example if you compare |
Naming this PR "Do not merge" was a stupid idea, that way it will never get merged... 😂 jokes aside, I try to get this updated and tests added soon. would be great for 2.x I suppose. |
a5de12b
to
50d120a
Compare
I'm sorry, I don't see this being merged :/ |
that's ok, no worries. is there anything I can do to change that or is it mostly based on experience/gut feeling (don't meant that in a bad way)? To me this still makes sense and kind of is the only way IMO to deal with that the linked issues show, also #2058 (comment) and the example there. but maybe there are edge cases I'm just not seeing yet and already have in mind or are worried about :) |
50d120a
to
25a5f87
Compare
I don't want to screw around https://phpstan.org/developing-extensions/type-system#type-normalization, and keeping benevolent union type separate from non-benevolent union type does that. |
25a5f87
to
bb6cfec
Compare
sorry, don't want to be too annoying here, but right now they are merged and not merging them keeps them more separate, no? just want to fully understand what might cause issues here. |
I don't want to keep them separate. |
ok, thx! I'll close this for now, not sure atm, but maybe there's a better way of dealing with the linked issues 😊 |
what about, yeah I know, I can't leave it alone 😂, the other way around? merging more aggressively: if stricter type checks are needed UPDATE: the more I think about it, the less I like it. Being less strict sounds bad :/ can we deprecate BenevolentUnionType? 😂 |
This was inspired by phpstan/phpstan#8458 (comment)
Closes phpstan/phpstan#7049
Closes phpstan/phpstan#7279
Closes phpstan/phpstan#7423
Closes phpstan/phpstan#8268
After this https://phpstan.org/r/498cd1d0-4568-4cbf-8b0b-11ed722552e8 becomes green.
Regarding the performance impact (#2058 (comment))
before:
after:
not sure if that is enough, the system is a bit trashy I guess. but looks like things don't really change perf.-wise. I'm pretty sure things also don't get faster, the variance is just too big on my system, I think we can go with 49s before and after.
Regarding the 3 failures
Cannot access offset (float|int<1, max>) on mixed.
https://github.com/pmmp/PocketMine-MP/blob/e0b07ff3087b652407439a29c941f3b66ca92c86/src/pocketmine/CrashDump.php#L314 / https://github.com/pmmp/PocketMine-MP/blob/e0b07ff3087b652407439a29c941f3b66ca92c86/src/pocketmine/CrashDump.php#L111ArrayObject<*NEVER*, *NEVER*>
https://github.com/PrestaShop/PrestaShop/blob/ca9d81aae0bb17f3e767bb5d835348ed144a3ab5/src/Adapter/Presenter/AbstractLazyArray.php#L98ArrayObject<*NEVER*, *NEVER*>
, e.g. https://github.com/sebastianbergmann/phpunit/blob/93d4bf4c37aec6384bb9e5d390d9049a463a7256/tests/unit/Framework/AssertTest.php#L153all of those are expected IMO, but I can create PRs for Prestashop and PHPUnit to add PHPDoc types to the collection if wanted