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

First class callable method crashes on undefined object variable #7815

Closed
michaeldnelson opened this issue Mar 24, 2022 · 4 comments
Closed

Comments

@michaeldnelson
Copy link

michaeldnelson commented Mar 24, 2022

https://psalm.dev/r/16a7bedf08

$z = $x->do(...);

I would expect this to report undefined variable $x, instead it crashes with an internal error.

For additional context, I discovered this while trying recreate an assert(!$this->isFirstClassCallable()) error I keep getting in my project but was not able to reproduce in the online parser. I'm hoping it is related.

Thanks!

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/16a7bedf08
<?php

$z = $x->do(...);
Psalm encountered an internal error:

/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php: Psalm\Internal\Analyzer\Statements\Expression\Call\ArgumentsAnalyzer::evaluateArbitraryParam(): Argument #2 ($arg) must be of type PhpParser\Node\Arg, PhpParser\Node\VariadicPlaceholder given, called in /vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php on line 127

@orklah
Copy link
Collaborator

orklah commented Mar 25, 2022

Definitely related. Unfortunately, the online parser is badly configured and does not crash when asserting fail, so it just continues through it

@weirdan
Copy link
Collaborator

weirdan commented Dec 3, 2022

Reports UndefinedGlobalVariable now: https://psalm.dev/r/16a7bedf08

Likely fixed by #8814

@weirdan weirdan closed this as completed Dec 3, 2022
@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/16a7bedf08
<?php

$z = $x->do(...);
Psalm output (using commit 14d48a0):

ERROR: UndefinedGlobalVariable - 3:6 - Cannot find referenced variable $x in global scope

INFO: MixedMethodCall - 3:10 - Cannot determine the type of $x when calling method do

INFO: UnusedVariable - 3:1 - $z is never referenced or the value is not used

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

3 participants