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

Unexpected TypeDoesNotContainType with optional array keys #2681

Closed
weirdan opened this issue Jan 23, 2020 · 1 comment
Closed

Unexpected TypeDoesNotContainType with optional array keys #2681

weirdan opened this issue Jan 23, 2020 · 1 comment
Labels

Comments

@weirdan
Copy link
Collaborator

weirdan commented Jan 23, 2020

https://psalm.dev/r/d082e5d948
Expected: no issue, as $d['r'] may be empty (not initialized)

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/d082e5d948
<?php
  
$d = [];
if (!rand(0,1)) {
  $d['r'] = 'a';
}

if (empty($d['r'])) {
}
Psalm output (using commit 0ffb833):

ERROR: TypeDoesNotContainType - 8:5 - Found a contradiction when evaluating $d['r'] and trying to reconcile type 'string(a)' to empty

@muglug muglug added the bug label Jan 24, 2020
@muglug muglug closed this as completed in c87b19e Jan 24, 2020
kkmuffme added a commit to kkmuffme/psalm that referenced this issue Jan 13, 2024
…hen not validated

Fix https://psalm.dev/r/b153d0d248 to return 'a'|null instead of 'a' - this is required as otherwise empty would report RedundantCondition errors now which would bring back vimeo#2681
kkmuffme added a commit to kkmuffme/psalm that referenced this issue Jan 13, 2024
…hen not validated

Fix https://psalm.dev/r/b153d0d248 to return 'a'|null instead of 'a' - this is required as otherwise empty would report RedundantCondition errors now which would bring back vimeo#2681
kkmuffme added a commit to kkmuffme/psalm that referenced this issue Jan 13, 2024
…hen not validated

Fix https://psalm.dev/r/b153d0d248 to return 'a'|null instead of 'a' - this is required as otherwise empty would report RedundantCondition errors now which would bring back vimeo#2681
kkmuffme added a commit to kkmuffme/psalm that referenced this issue Jan 15, 2024
…hen not validated

Fix https://psalm.dev/r/b153d0d248 to return 'a'|null instead of 'a' - this is required as otherwise empty would report RedundantCondition errors now which would bring back vimeo#2681
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