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

unset doesn't change array shape #6343

Closed
AndrolGenhald opened this issue Aug 19, 2021 · 3 comments · Fixed by #6346
Closed

unset doesn't change array shape #6343

AndrolGenhald opened this issue Aug 19, 2021 · 3 comments · Fixed by #6346
Labels

Comments

@AndrolGenhald
Copy link
Collaborator

https://psalm.dev/r/ca6bce5b16

The second trace should only have array{b: 2}.

@psalm-github-bot
Copy link

I found these snippets:

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

$test = ['a' => 1, 'b' => 2];
/** @psalm-trace $test */;
unset($test['a']);
/** @psalm-trace $test */;
Psalm output (using commit 9e1f7ad):

INFO: Trace - 4:26 - $test: array{a: 1, b: 2}

INFO: Trace - 6:26 - $test: array{a: 1, b: 2}

@weirdan
Copy link
Collaborator

weirdan commented Aug 19, 2021

Affects trace only: https://psalm.dev/r/c95337fb10

@psalm-github-bot
Copy link

I found these snippets:

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

$test = ['a' => 1, 'b' => 2];

echo atan($test['a']);

unset($test['a']);

echo atan($test['a']);

/** @psalm-trace $test */;
Psalm output (using commit 9e1f7ad):

ERROR: InvalidArrayOffset - 9:11 - Cannot access value on variable $test using offset value of 'a', expecting 'b'

INFO: MixedArgument - 9:11 - Argument 1 of atan cannot be mixed, expecting float

INFO: Trace - 11:26 - $test: array{a: 1, b: 2}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants