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

Casting int range should keep literals #10940

Closed
kkmuffme opened this issue May 3, 2024 · 1 comment · Fixed by #10941
Closed

Casting int range should keep literals #10940

kkmuffme opened this issue May 3, 2024 · 1 comment · Fixed by #10941

Comments

@kkmuffme
Copy link
Contributor

kkmuffme commented May 3, 2024

https://psalm.dev/r/b6f6d6b075

For a reasonable int range size, casting an int range should behave like casting int's that aren't in a range.

Copy link

I found these snippets:

https://psalm.dev/r/b6f6d6b075
<?php

$int = rand(0, 2);
$string = (string) $int;
/** @psalm-trace $string */;

$int = rand(0, 1) ? 0 : 2;
$string = (string) $int;
/** @psalm-trace $string */;
Psalm output (using commit 08afc45):

INFO: Trace - 5:28 - $string: numeric-string

INFO: Trace - 9:28 - $string: '0'|'2'

INFO: UnusedVariable - 3:1 - $int is never referenced or the value is not used

INFO: UnusedVariable - 4:1 - $string is never referenced or the value is not used

INFO: UnusedVariable - 7:1 - $int is never referenced or the value is not used

INFO: UnusedVariable - 8:1 - $string is never referenced or the value is not used

kkmuffme added a commit to kkmuffme/psalm that referenced this issue May 3, 2024
Fix vimeo#10940
500 limit taken from TypeCombiner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant