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

Illegal [,] is allowed in psysh #543

Closed
zhujinxuan opened this issue Dec 20, 2018 · 5 comments
Closed

Illegal [,] is allowed in psysh #543

zhujinxuan opened this issue Dec 20, 2018 · 5 comments

Comments

@zhujinxuan
Copy link

Hi, the following sentence is allowed in psysh but disallowed in php -a:

$a = [,];

In php 7.3.0, it will give an error that

php > $a = [,];
PHP Fatal error:  Cannot use empty array elements in arrays in php shell code on line 1

Fatal error: Cannot use empty array elements in arrays in php shell code on line 1
@GrahamCampbell
Copy link
Contributor

Is this supported in PHP 7.3?

@GrahamCampbell
Copy link
Contributor

Sorry, I meant 7.2.

@bobthecow
Copy link
Owner

Same error in PHP 7.2.

I think the underlying issue is likely with PHP-Parser. It parses $a = [,]; without complaint, which means, after we write the AST back to PHP, we don't have an invalid array anymore:

screen shot 2018-12-20 at 7 10 29 pm

@zhujinxuan
Copy link
Author

I see. Perhaps there are also similar trialing comma problems in PHP-Parser and tolerant-PHP-Parser php/php-langspec#229

I will submit PRs about that to PHP-parser before Christmas, then we can see whether the problem is fixed by a simple update.

@bobthecow
Copy link
Owner

Since this is an issue in PHP-Parser, closing this one in favor of nikic/PHP-Parser#561 :)

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

No branches or pull requests

3 participants