vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.49k stars 655 forks source link

AssertionError on taint-analysis of the first-class-callables #9109

Open alies-dev opened 1 year ago

alies-dev commented 1 year ago

https://psalm.dev/r/0eddd75e6b (not reproducible as it's not possible to enable taint-analysis)

Affected versions: 5.4.0, master 11942d7

Uncaught Exception: AssertionError assert(!$this->isFirstClassCallable()) (23%)
Emitted in some_dirpsalm/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php:36
Stack trace in the forked worker:
#0 some_dirpsalm/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php(36): assert(false, 'assert(!$this->...')
#1 some_dirpsalm/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php(658): PhpParser\Node\Expr\CallLike->getArgs()
#2 some_dirpsalm/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php(264): Psalm\Internal\Analyzer\Statements\Expression\Call\FunctionCallReturnTypeFetcher::taintReturnType(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\FuncCall), 'trim', Object(Psalm\Storage\FunctionStorage), Object(Psalm\Type\Union), Object(Psalm\Internal\Type\TemplateResult), Object(Psalm\Context))
#3 some_dirpsalm/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php(252): Psalm\Internal\Analyzer\Statements\Expression\Call\FunctionCallReturnTypeFetcher::fetch(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(Psalm\Codebase), Object(PhpParser\Node\Expr\FuncCall), Object(PhpParser\Node\Name), 'trim', true, true, Object(Psalm\Storage\FunctionStorage), NULL, Object(Psalm\Internal\Type\TemplateResult), Object(Psalm\Context))
#4 some_dirpsalm/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php(296): Psalm\Internal\Analyzer\Statements\Expression\Call\FunctionCallAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\FuncCall), Object(Psalm\Context), Object(Psalm\Internal\Type\TemplateResult))
#5 some_dirpsalm/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php(86): Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer::handleExpression(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\FuncCall), Object(Psalm\Context), false, NULL, false, NULL, false)
psalm-github-bot[bot] commented 1 year ago

I found these snippets:

https://psalm.dev/r/0eddd75e6b ```php $l */ function trimArray(array $l): array { return array_map(trim(...), $l); } ``` ``` Psalm output (using commit 11942d7): No issues! ```
orklah commented 1 year ago

https://psalm.dev/r/d13ceae033

psalm-github-bot[bot] commented 1 year ago

I found these snippets:

https://psalm.dev/r/d13ceae033 ```php $l */ function trimArray(array $l): array { return array_map(trim(...), $l); } ``` ``` Psalm encountered an internal error: /vendor/vimeo/psalm/src/Psalm/CodeLocation.php: Psalm\CodeLocation::__construct(): Argument #2 ($stmt) must be of type PhpParser\Node, null given, called in /vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php on line 715 ```
Norbytus commented 3 days ago

Any updates?