-
Notifications
You must be signed in to change notification settings - Fork 660
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
Regression with RedundantConditionGivenDocblockType and DocblockTypeContradiction #10715
Comments
I found these snippets: https://psalm.dev/r/892d59e94e<?php
/**
* @param array<string, true> $array
*/
function func(array $array): int
{
if (!empty($array['stuff'])) return 1;
if (empty($array['more stuff'])) return 2;
return 3;
}
|
Possibly related: #10716 |
If you enable https://psalm.dev/docs/running_psalm/configuration/#ensurearraystringoffsetsexist in your config, do you still get this error? |
@kkmuffme well, the default setting for ensureArrayStringOffsetsExist is false, so when I set it to true, I only get new errors, no existing errors get removed (saved reports and made a diff). So these RedundantConditionGivenDocblockType and DocblockTypeContradiction errors are not affected by ensureArrayStringOffsetsExist setting. Would have been cool to be able to change the config attributes in the paslm.dev playground :) |
You can change some of them by clicking the |
@weirdan yup! would be cool to have the rest of them (with their config names). This way it would be easier to reproduce some test cases, or even better a text area to paste a config! and a version selector for regression reproduction! but that's totally off-topic :) |
It's a bug bc of the Possibly the issue happens from https://github.com/vimeo/psalm/blob/5.x/src/Psalm/Internal/Analyzer/Statements/Expression/EmptyAnalyzer.php#L62 and below Give it a shot for a PR and report back if you need any help. |
I found these snippets: https://psalm.dev/r/6de6380bf7<?php
/**
* @param array<string, true> $array
*/
function func(array $array): int
{
if (isset($array['stuff'])) return 1;
if (!isset($array['more stuff'])) return 2;
return 3;
}
|
It's not. It's been discussed in more details here: #10578 (comment) |
Most likely it is, but I've no problem to keep both open until we figure out this for sure |
Hmm... the original snippet seems like it's still failing: https://psalm.dev/r/892d59e94e Should this issue be reopened? |
I found these snippets: https://psalm.dev/r/892d59e94e<?php
/**
* @param array<string, true> $array
*/
function func(array $array): int
{
if (!empty($array['stuff'])) return 1;
if (empty($array['more stuff'])) return 2;
return 3;
}
|
Psalm incorrectly reports truthy and falsy values, and marks a redundant check or a doc type contradiction:
This broke in 5.19.1 I think
Consider:
Psalm returns:
https://psalm.dev/r/892d59e94e
The text was updated successfully, but these errors were encountered: