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

Array shape information lost after spread #10873

Open
egst opened this issue Apr 2, 2024 · 2 comments
Open

Array shape information lost after spread #10873

egst opened this issue Apr 2, 2024 · 2 comments

Comments

@egst
Copy link

egst commented Apr 2, 2024

When using the spread operator on an array with optional fields in the array shape, the array shape information is lost. Is that intentional?

https://psalm.dev/r/a552a530a6

Copy link

I found these snippets:

https://psalm.dev/r/a552a530a6
<?php

/** @return array{foo?: string, boo?: int} */
function f (): array {
	return ['foo' => 'bar', 'boo' => 3];
}

$a = [...f()];

/** @psalm-trace $a */;
Psalm output (using commit ef3b018):

INFO: Trace - 10:23 - $a: array<'boo'|'foo', int|string>

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

@kkmuffme
Copy link
Contributor

kkmuffme commented Apr 6, 2024

Maybe fixed by #10777 but it's been too long so I can't remember. Otherwise it would be trivial to fix this behavior once this PR is merged to not get tons of conflicts introduced

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