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

check "never" return type more strictly #8624

Merged
merged 1 commit into from Dec 1, 2022

Conversation

kkmuffme
Copy link
Contributor

@orklah
Copy link
Collaborator

orklah commented Oct 27, 2022

This snippet should still be working:
https://psalm.dev/r/3ec4cb4877

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/3ec4cb4877
<?php

abstract class Car{
 	abstract public function getFuel(): string{}   
}

class ThermalCar{
 	public function getFuel(): string { return 'Gas';}
}

class ElectricCar{
 	public function getFuel(): never { throw new DomainException('EV need no fuel'); }
}
Psalm output (using commit 7c83878):

No issues!

@kkmuffme kkmuffme force-pushed the check-never-return-more-strictly-v5 branch 3 times, most recently from ab37a7a to b2acba2 Compare November 10, 2022 15:58
@kkmuffme
Copy link
Contributor Author

The failing test is unrelated to the changes of this PR.

As discussed it won't give an error for #8175 (comment) / #8624

Ready for review

@kkmuffme kkmuffme marked this pull request as ready for review November 10, 2022 16:43
@kkmuffme
Copy link
Contributor Author

kkmuffme commented Dec 1, 2022

@orklah if I resolve the conflicts which popped up in the meantime, could this get reviewed & merged now?

@orklah
Copy link
Collaborator

orklah commented Dec 1, 2022

Yeah probably, did you check the snippet I posted above?

@kkmuffme
Copy link
Contributor Author

kkmuffme commented Dec 1, 2022

Afair yes, this is still working without errors. (I even added a test for a similar case)

* require explicit "never" return type when function always exits, except if it only throws
* error if function does not exit, but return type explicitly contains "never"
* Fix: vimeo#8175
* Fix: vimeo#8178
@kkmuffme kkmuffme force-pushed the check-never-return-more-strictly-v5 branch from b2acba2 to 694b7d8 Compare December 1, 2022 13:52
@orklah orklah added enhancement release:feature The PR will be included in 'Features' section of the release notes and removed enhancement labels Dec 1, 2022
@orklah orklah merged commit aee4605 into vimeo:master Dec 1, 2022
@orklah
Copy link
Collaborator

orklah commented Dec 1, 2022

Thanks!

kkmuffme added a commit to kkmuffme/psalm that referenced this pull request Dec 29, 2022
kkmuffme added a commit to kkmuffme/psalm that referenced this pull request Dec 29, 2022
Fix never return union type wrong condition

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

Successfully merging this pull request may close these issues.

InvalidReturnType due to void and null not treated the same Missing InvalidReturnType check when exit;
2 participants