-
Notifications
You must be signed in to change notification settings - Fork 663
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
print
, exit
, and die
effect IO but they are considered pure.
#6136
Comments
I found these snippets: https://psalm.dev/r/f3713595ce<?php
/**
* @return (pure-callable(string): int)
* @pure
*/
function foo(): callable {
return fn(string $a) => print($a);
}
/**
* @pure
*/
function bar(): void {
$_x_ = foo()('h');
}
/**
* @pure
*/
function baz(): void {
print('x');
}
/**
* @pure
*/
function qux(): void {
exit('x');
}
/**
* @pure
*/
function quux(): void {
die('x');
}
|
Note: |
I'm onboard for print, but can you explain what's the desired behaviour for die() and exit()? From what I see, purity is only useful in the context of the process still running. Is this only for principle or does this have practical applications? |
a function signature might be I think die should only be considered pure when it's called without an argument. |
I can imagine cases where you may want to make sure no unexpected output generated. E.g. language server, generating images, etc. |
|
yea, so conditionally pure if the type of the argument is not a string. |
I can pick this up if it hasn't already been started, I've briefly looked into the issue and can see that it's caused by both the |
ref: https://psalm.dev/r/f3713595ce
The text was updated successfully, but these errors were encountered: