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

Function names cannot be keywords #236

Open
mattacosta opened this issue Feb 27, 2018 · 4 comments
Open

Function names cannot be keywords #236

mattacosta opened this issue Feb 27, 2018 · 4 comments
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@mattacosta
Copy link

Summary
A function name must be a T_STRING token (or whatever its equivalent is in this parser).

Sample code:
function empty() {}

Expected
Parse error: syntax error, unexpected 'empty' (T_EMPTY), expecting '('

Actual
No error.

@jens1o
Copy link
Contributor

jens1o commented Feb 28, 2018

You may not redeclare language constructs.

@TysonAndre
Copy link
Contributor

TysonAndre commented Feb 28, 2018

https://3v4l.org/90mgr

It is still a parse error which should be detected. To contrast, function strlen($s) {} would not be a parse error, but evaluation would result in a PHP error at runtime.

Also something to note: empty is a valid name for a class method in PHP 7

@felixfbecker
Copy link

@jens1o empty is a language construct, not a function

@jens1o
Copy link
Contributor

jens1o commented Feb 28, 2018

Nice catch :)

@roblourens roblourens added the bug Issue identified by VS Code Team member as probable bug label Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

5 participants