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

Assertion does not work on constants - mixed error for const even when checked they exist #9770

Open
kkmuffme opened this issue May 11, 2023 · 3 comments

Comments

@kkmuffme
Copy link
Contributor

https://psalm.dev/r/81e33cf2b7

Should be "string" in both cases, not mixed.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/81e33cf2b7
<?php

$value = '';
if( defined( 'MY_CONST' ) && is_string( MY_CONST ) ) {
    $value = MY_CONST;
    /** @psalm-trace $value */;
}

/** @psalm-trace $value */;
Psalm output (using commit 841cccd):

INFO: MixedAssignment - 5:5 - Unable to determine the type that $value is being assigned to

INFO: Trace - 6:31 - $value: mixed

INFO: Trace - 9:27 - $value: ''|mixed

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

INFO: UnusedVariable - 5:5 - $value is never referenced or the value is not used

@kkmuffme
Copy link
Contributor Author

kkmuffme commented Jul 3, 2023

I guess this was fixed (by the now reverted) #7054 as explained in #7241 (comment) ? @orklah

@orklah
Copy link
Collaborator

orklah commented Jul 3, 2023

The revert was in #7263 and it was because it produced things like #7262

Honestly, loop analysis is something I have a hard time wrapping my head around so when something affects loops, I'm pretty much helpless

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

No branches or pull requests

2 participants