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

Psalm 5: crash with references #7580

Closed
pilif opened this issue Feb 4, 2022 · 3 comments
Closed

Psalm 5: crash with references #7580

pilif opened this issue Feb 4, 2022 · 3 comments

Comments

@pilif
Copy link
Contributor

pilif commented Feb 4, 2022

https://psalm.dev/r/0bb7071d6d

Uncaught Error: Attempt to modify property "parent_nodes" on null in <project>/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php:975
@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/0bb7071d6d
<?php

function func(&$a)
{
    $_ = &$a['f'];
}
Psalm encountered an internal error:

/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php: Attempt to modify property "parent_nodes" on null

@AndrolGenhald
Copy link
Collaborator

It looks like this is because analyzing $a['f'] doesn't add $a['f'] to $vars_in_scope if it's mixed. This works fine. I'll get it fixed shortly.

@psalm-github-bot
Copy link

I found these snippets:

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

/**
 * @param array{f: int} $a
 */
function func(&$a)
{
    $b = &$a['f'];
}
Psalm output (using commit c5722dd):

INFO: UnusedVariable - 8:5 - $b is never referenced or the value is not used

INFO: UnusedParam - 6:16 - Param $a is never referenced in this method

INFO: MissingReturnType - 6:10 - Method func does not have a return type, expecting void

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

No branches or pull requests

4 participants