-
Notifications
You must be signed in to change notification settings - Fork 46
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
Meriyah does not properly follow ECMA standards on function declaration and calling. #182
Comments
Probably missed check in Line 391 in 3c0b156
|
@KFlash what's this line doing? Line 4800 in 3c0b156
It says |
validates func names and remove module and strict check |
Why shift 11 bits? |
I think I missed the leading |
then rewrite it. I guess that logic broke at some point where token.ts was updated with support for newer AST nodes |
That logic was not the reason of this bug. I am just curious about the line which I still don't understand. |
The logic is - I think - is that await and yield has a value around 21? Then you shift to left so you can unset this masks. Doing so will let you validate cases that should be valid even in async or yield context |
There are lots of missed rejection on CallExpression, for example: ["a"]();
var a = {a:1}();
null();
true();
false(); It's bit hard to clear up all of them, which leads me to think maybe our I fixed all the above, but surely there are more (mainly in parsePrimaryExpression). |
@KFlash some interesting finding. In real JS parser (nodejs), function a() { null(); }
a(); // error throws on this line, not previous line I guess we don't need to reject the 3 in parsing. |
My lord function a() { "a"() } This parses with no issue in browser or nodejs. @KFlash I guess we don't change the rejections of CallExpression at all? |
|
Other parsers like acorn and TS do not reject them. |
Apologies. |
@LumenUI nothing to be sorry for. It was a valid point, and very subtle and surprising behavior, which clarified some edge cases.
|
NVM, my mistake, |
When experimenting with Meriyah, I discovered the parser properly registers the following invalid function declarations and calls:
Meriyah also struggles when calling functions. It will assume that the name of the function being called is an identifier, and not a literal.
The text was updated successfully, but these errors were encountered: