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 fatal error #314

Closed
lchrusciel opened this issue Apr 30, 2020 · 4 comments
Closed

Psalm fatal error #314

lchrusciel opened this issue Apr 30, 2020 · 4 comments

Comments

@lchrusciel
Copy link

lchrusciel commented Apr 30, 2020

Since: v.2.4.3

At @Sylius, we are using psalm pretty extensively. Recently, we have experienced some strange errors connected to your library. Psalm is reporting that you have some Unterminated bracket (ref. https://travis-ci.org/github/Sylius/SyliusResourceBundle/jobs/681382237).

I don't have time to dig into it right now, so I cannot determine where the problem lays. However, I'm sure that limiting your library below 2.4.3 solves the issue for us. We do not have a direct dependency on you, so I've decided to temporary conflict with the newest releases, which fixed our builds: Sylius/SyliusResourceBundle#163 and Sylius/SyliusResourceBundle#161

If you would be interested, here are some logs:

Registering autoloaded files
Parsing /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/amphp/amp/lib/functions.php
Deep scanning /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/amphp/amp/lib/functions.php
Uncaught Psalm\Exception\TypeParseTreeException: Unterminated bracket in /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/vimeo/psalm/src/Psalm/Internal/Type/ParseTree.php:604
Stack trace:
#0 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/vimeo/psalm/src/Psalm/Type.php(175): Psalm\Internal\Type\ParseTree::createFromTokens(Array)
#1 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(2680): Psalm\Type::parseTokens(Array)
#2 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(2213): Psalm\Internal\Visitor\ReflectorVisitor->getAssertionParts('array<array-key...', Object(PhpParser\Node\Stmt\Function_))
#3 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(323): Psalm\Internal\Visitor\ReflectorVisitor->registerFunctionLike(Object(PhpParser\Node\Stmt\Function_))
#4 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(200): Psalm\Internal\Visitor\ReflectorVisitor->enterNode(Object(PhpParser\Node\Stmt\Function_))
#5 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray(Array)
#6 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\Namespace_))
#7 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(91): PhpParser\NodeTraverser->traverseArray(Array)
#8 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/vimeo/psalm/src/Psalm/Internal/Scanner/FileScanner.php(96): PhpParser\NodeTraverser->traverse(Array)
#9 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(606): Psalm\Internal\Scanner\FileScanner->scan(Object(Psalm\Codebase), Object(Psalm\Storage\FileStorage), false, Object(Psalm\Progress\DebugProgress))
#10 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(389): Psalm\Internal\Codebase\Scanner->scanFile('/Users/chrustu/...', Array, true)
#11 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(497): Psalm\Internal\Codebase\Scanner->Psalm\Internal\Codebase\{closure}(0, '/Users/chrustu/...')
#12 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(347): Psalm\Internal\Codebase\Scanner->scanFilePaths(1)
#13 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/vimeo/psalm/src/Psalm/Config.php(1707): Psalm\Internal\Codebase\Scanner->scanFiles(Object(Psalm\Internal\Codebase\ClassLikes))
#14 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/vimeo/psalm/src/psalm.php(506): Psalm\Config->visitComposerAutoloadFiles(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), Object(Psalm\Progress\DebugProgress))
#15 /Users/chrustu/Sites/Sylius/SyliusResourceBundle/vendor/vimeo/psalm/psalm(2): require_once('/Users/chrustu/...')
#16 {main}
(Psalm 3.8.1@8e54e3aa060fc490d86d0e2abbf62750516d40fd crashed due to an uncaught Throwable)

I just wanted to keep you informed. Maybe some have a similar issue.

Have a good day :)

@bwoebi
Copy link
Member

bwoebi commented Apr 30, 2020

amphp/amp currently requires psalm 3.11; you could try upgrading your psalm version - psalm 3.8 still has a few issues with templating and generics.

@bwoebi
Copy link
Member

bwoebi commented Apr 30, 2020

@kelunik Perhaps it would make sense to explicitly add a conflicts "vimeo/psalm" rule to composer.json for <=3.11 so that this won't happen. (at least the next time we bump the psalm dep)

@lchrusciel
Copy link
Author

Thanks, I can confirm that your advice works: Sylius/SyliusResourceBundle#164

I was expecting something like this, however, I couldn't find this hint. Maybe it will help others in the future.

@kelunik
Copy link
Member

kelunik commented Apr 30, 2020

@bwoebi that might be a good idea, yes.

GSadee added a commit to Sylius/Sylius that referenced this issue May 7, 2020
This PR was merged into the 1.7 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.7
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | 
| License         | MIT

Should resolve:
```bash
PHP Fatal error:  Uncaught Psalm\Exception\TypeParseTreeException: Unterminated bracket in /home/travis/build/Sylius/Sylius/vendor/vimeo/psalm/src/Psalm/Internal/Type/ParseTree.php:571
Stack trace:
#0 /home/travis/build/Sylius/Sylius/vendor/vimeo/psalm/src/Psalm/Type.php(171): Psalm\Internal\Type\ParseTree::createFromTokens(Array)
#1 /home/travis/build/Sylius/Sylius/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(2668): Psalm\Type::parseTokens(Array)
#2 /home/travis/build/Sylius/Sylius/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(2207): Psalm\Internal\Visitor\ReflectorVisitor->getAssertionParts('array<array-key...', Object(PhpParser\Node\Stmt\Function_))
#3 /home/travis/build/Sylius/Sylius/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(323): Psalm\Internal\Visitor\ReflectorVisitor->registerFunctionLike(Object(PhpParser\Node\Stmt\Function_))
#4 /home/travis/build/Sylius/Sylius/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(200): Psalm\Internal\Visitor\Reflect in /home/travis/build/Sylius/Sylius/vendor/vimeo/psalm/src/Psalm/Internal/Type/ParseTree.php on line 571
Fatal error: Uncaught Psalm\Exception\TypeParseTreeException: Unterminated bracket in /home/travis/build/Sylius/Sylius/vendor/vimeo/psalm/src/Psalm/Internal/Type/ParseTree.php:571
Stack trace:
#0 /home/travis/build/Sylius/Sylius/vendor/vimeo/psalm/src/Psalm/Type.php(171): Psalm\Internal\Type\ParseTree::createFromTokens(Array)
#1 /home/travis/build/Sylius/Sylius/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(2668): Psalm\Type::parseTokens(Array)
#2 /home/travis/build/Sylius/Sylius/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(2207): Psalm\Internal\Visitor\ReflectorVisitor->getAssertionParts('array<array-key...', Object(PhpParser\Node\Stmt\Function_))
#3 /home/travis/build/Sylius/Sylius/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(323): Psalm\Internal\Visitor\ReflectorVisitor->registerFunctionLike(Object(PhpParser\Node\Stmt\Function_))
#4 /home/travis/build/Sylius/Sylius/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(200): Psalm\Internal\Visitor\Reflect in /home/travis/build/Sylius/Sylius/vendor/vimeo/psalm/src/Psalm/Internal/Type/ParseTree.php on line 571
```

Ref. https://travis-ci.org/github/Sylius/Sylius/jobs/682877325
Ref. amphp/amp#314

<!--
 - Bug fixes must be submitted against the 1.6 or 1.7 branches (the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set
-->


Commits
-------

f6819a2 [Maintenance] Upgrade psalm version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants