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

no-return type breaks whole union in @return #5652

Closed
someniatko opened this issue Apr 20, 2021 · 1 comment
Closed

no-return type breaks whole union in @return #5652

someniatko opened this issue Apr 20, 2021 · 1 comment
Labels

Comments

@someniatko
Copy link
Contributor

someniatko commented Apr 20, 2021

This is a minimal reproducer of the problem:
https://psalm.dev/r/3b5004a09a

no-return is a "bottom type", this means it should be a subtype of all types. But for now it "contaminates" the return type of
any function and Psalm just thinks it must not return nothing at all, even if there are other non-bottom types in the union.

You can see where I have to use this type in practice in the following repo, which is a simple library for FP-ish Result type (Success or Error), and where I encountered this error:
https://github.com/someniatko/php-result-type

@psalm-github-bot
Copy link

I found these snippets:

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

/** @return int|no-return */
function returnSomething(): int
{
    return 1;
}
Psalm output (using commit 39e61ae):

ERROR: InvalidReturnType - 3:13 - returnSomething is not expected to return any values but it does, either implicitly or explicitly

@weirdan weirdan added the bug label Apr 20, 2021
@muglug muglug closed this as completed in ecd5e3b Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants