-
Notifications
You must be signed in to change notification settings - Fork 667
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
AssertionError assert(count($result_type_parts) === $combinations)
#9285
Comments
I found these snippets: https://psalm.dev/r/78d9b454f0<?php
class Request {
public function input(string $name): mixed
{
return $_POST[$name] ?? null;
}
}
function show(Request $request): void
{
$publicationType = $request->input('publicationType');
$publicationId = $request->input('publicationId');
$publication = null;
if ($publicationType === 'article') {
$publication = Article::query()->findOrFail($publicationId);
} elseif ($publicationType === 'book-chapter') {
$publication = BookChapter::query()->findOrFail($publicationId);
} else {
/** abort without a valid publication */
abort(Response::HTTP_NOT_FOUND, 'Content not found.');
}
assert($publication instanceof Taggable);
}
|
Stack trace suggests something different. Namely, it appears Psalm was analyzing an expression like |
I got the same issue today on running PHP 8.1.14 (cli)
|
interesting, I still have this issue on both locally installed PHP version (8.1.15, 8.2.2, macOS, installed using brew). I decided to debug it a bit, added a custom assertion message like this: assert(count($result_type_parts) === $combinations, sprintf("%s(%s) & %s(%s)", count($result_type_parts), get_debug_type(count($result_type_parts)), $combinations, get_debug_type($combinations))); And output is:
I'm not even sure where to report it - to PHP, to brew or other places? 🤯 On Docker instances of PHP it works fine |
To https://github.com/php/php-src/, I suppose, but you'll need a better reproducer. One thing that's worth checking is reducing the set of extensions used to the bare minimum (see below) psalm/src/Psalm/Internal/CliUtils.php Lines 521 to 536 in d6c47ae
|
FWIW, I am having the same issue on Mac (8.1.15, 8.2.3) when using psalm 5.7.0/5.7.1. On Linux (8.1.15), it works fine. Psalm 5.6.0 also works fine on both platforms. |
Already reported to php/php-src#10635, a workaround for psalm is present in #9351 and should be tagged as 5.7.2 |
The fix is released in 5.7.2. |
Does this workaround address the issue for everybody? I'm still experiencing this error message in 5.7.4. |
@pereorga Mind opening a new issue with a reproducer? |
5.7.4: I also still have it:
|
Either way the bug will be fixed directly inside of PHP itself in PHP 8.1.17, 8.2.4. |
Today I tried to update Psalm to the latest dev-master 1be367b, from 3584826 and caught an issue that I couldn't reproduce on psalm.dev
stack:
Laravel code where it failed:
Namely on line
$publication = Article::query()->findOrFail($publicationId);
Laravel plugin is not installed
Snippet where I could reproduce it (even if I define classes): https://psalm.dev/r/78d9b454f0
The text was updated successfully, but these errors were encountered: