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
Invalid provided type consolidation causes InvalidArgument error #8231
Comments
I found these snippets: https://psalm.dev/r/ef73d1b6b4<?php
$csv = array(
'foo,bar',
'hello,world',
);
process( array_map( 'str_getcsv', $csv ) );
/**
* @param array<int, string> $data
* @return void
*/
function process( $data ) {
print_r( $data );
}
https://psalm.dev/r/3549b6fa5a<?php
$csv = array(
'foo,bar',
'hello,world',
);
process( array_map( 'str_getcsv', $csv ) );
/**
* @param array<int, string[]> $data
* @return void
*/
function process( $data ) {
print_r( $data );
}
|
|
I found these snippets: https://psalm.dev/r/165b0a9c5c<?php
/** @var array<string, float> */
$arr = [];
$arr[1] = 2;
$arr[4] = 3;
/** @psalm-trace $arr */;
|
Note that you can use this syntax like this: But I hate it. It's not an intersection at all. I'd rather we parse the original syntax |
I found these snippets: https://psalm.dev/r/ff73b2dfb0<?php
/** @var array{1: 2, 4: 3}&array<string, float> $array */
$array = '';
/** @psalm-trace $array */;
|
So basically you are saying this issue could be fixed by just replacing |
I wouldn't accept such a PR. That syntax need to be replaced, not normalized |
https://psalm.dev/r/ef73d1b6b4
I think there is a bug with the type consolidation, as the
provided
type in error is invalidarray{non-empty-list<string>, non-empty-list<string>}<non-empty-list<string>>
When I put the correct type, then no error https://psalm.dev/r/3549b6fa5a
However I think it needs to have the "provided" type fixed to a valid type, so the error message makes sense
The text was updated successfully, but these errors were encountered: