Skip to content

Raise a more intelligible error when trying to convert static method with name eqal to constructor #86

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

Closed
danog opened this issue Aug 29, 2017 · 3 comments
Assignees

Comments

@danog
Copy link

danog commented Aug 29, 2017

When trying to convert a static method constructor, the parser throws an unintelligible error, Parse Error : syntax error, unexpected 'function Object() { [native code] }', expecting T_STRING on line n, a more specific error would be nice for JS newbies.

Example code that triggers the error:

<?php class a { public static function constructor() {} }
@danog
Copy link
Author

danog commented Aug 29, 2017

The same happens when trying to call a static function with name constructor

<?php anyClass::constructor();

Or when having a normal method with name constructor:

<?php class a { public function constructor() {} }

<?php $classinstance->constructor(); works though

@ichiriac ichiriac self-assigned this Aug 29, 2017
@ichiriac
Copy link
Member

Hi @danog,

Many thanks for the bug report. Need to dig a little, but for me this is due to the fact that the function name is used/indexed somewhere as a property over an object.

I can reproduce the same behavior on :

<?php class a { 
  public function __proto__() {} 
}

I'll work on it in few days, maybe will release it this week-end

ichiriac added a commit that referenced this issue Sep 3, 2017
@ichiriac
Copy link
Member

ichiriac commented Sep 3, 2017

released under 2.0.7

@ichiriac ichiriac closed this as completed Sep 3, 2017
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

2 participants