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

Fix conflicting array_map return provider fake variables. #7167

Merged

Conversation

AndrolGenhald
Copy link
Collaborator

Fix array_map return provider fake variables conflicting when nesting array_map calls (fixes #7164).
Ensure all fake variables are removed from context.

@weirdan weirdan added the release:fix The PR will be included in 'Fixes' section of the release notes label Dec 15, 2021
@AndrolGenhald
Copy link
Collaborator Author

As noted in #7164, $x['$__fake_offset_var__] was being left in the context by ArrayMapReturnTypeProvider. I added a unique id to the fake variables to allow for easy cleanup, and it fixed the main issue as well, which I assume was due to the name being re-used and removed from the context on the inner call while it was still needed for the outer call, or vice versa.

@weirdan
Copy link
Collaborator

weirdan commented Dec 15, 2021

Would you mind adding a test for this case?

@AndrolGenhald
Copy link
Collaborator Author

Would you mind adding a test for this case?

Completely slipped my mind, I have a .git/info/excluded test file that I test things like this with locally and I forgot to copy the test over to a committed file.

@orklah
Copy link
Collaborator

orklah commented Dec 15, 2021

Can you maybe rename var_id into var_seed or something? var_id is already used a lot in Psalm to refer to actual variable identifiers(or fake ones), so in your case, the var_id would be __fake_{$fake_var_id}_offset_var__ instead

@AndrolGenhald AndrolGenhald force-pushed the bugfix/7164-conflicting-fake-variable branch from 4892501 to d62bee3 Compare December 15, 2021 17:33
@weirdan weirdan merged commit 7e97c5c into vimeo:master Dec 15, 2021
@weirdan
Copy link
Collaborator

weirdan commented Dec 15, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix The PR will be included in 'Fixes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UndefinedVariable "$__fake_offset_var__"
3 participants