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

Parser crashes on obscure PHP list syntax with missing arguments #44

Closed
tylerchr opened this issue Jun 26, 2018 · 1 comment
Closed
Assignees
Labels

Comments

@tylerchr
Copy link
Contributor

I discovered today that the parser fails with an "index out of range" runtime error when it encounters the following PHP code:

<?php
$things = ["foo", "bar"];
list(, $bar) = $things;

Surprisingly, this is valid PHP code (running it results in bar).

php-parser gets really unhappy about the lack of a first argument though:

panic: runtime error: index out of range

I almost feel bad reporting this because it's such bad PHP code, but it's nonetheless valid and should probably at least not crash the parser.

@z7zmey
Copy link
Owner

z7zmey commented Jun 26, 2018

There was a bug. I tried to save comments to nil element.

Now parser does not trim first nil, which represents the missed item.
Also, it does not trim last nil if array item list ends by a comma.

@z7zmey z7zmey closed this as completed Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants