Skip to content

A possible issue with CC not throwing syntax exceptions correctly #6553

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
ty5491003 opened this issue Dec 26, 2020 · 2 comments · Fixed by #6854
Closed

A possible issue with CC not throwing syntax exceptions correctly #6553

ty5491003 opened this issue Dec 26, 2020 · 2 comments · Fixed by #6854

Comments

@ty5491003
Copy link

Chakra Version

Latest Commit 9e2f198 (Release Version)

Test case
if (1)
Execution steps
./ChakraCore/out/Release/ch testcase.js
Expected behavior
SyntaxError: Unexpected end of script
Actual behavior
(No exception was thrown)
Description

Obviously this is a syntax error, however CC does not throw any exceptions. I've tried other engines, and they all throw SyntaxError, So i suspect it's a bug.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Dec 26, 2020

Hmm comparing with v8, SM and JSC they throw a syntax error for eval("if(1)") BUT not for just if(1)

CC doesn't throw for either - clearly should throw for the eval case - unsure about the non-eval case.

Should be an easy fix in the parser.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Dec 26, 2020

This is actually a duplicate of #6351 though that issue speaks of for(;;) and this talks about if() the underlying issue is the same.

@rhuanjl rhuanjl closed this as completed Dec 26, 2020
rhuanjl pushed a commit that referenced this issue Oct 15, 2022
According to the Rules of Automatic Semicolon Insertion:

"a semicolon is never inserted automatically if the semicolon would then be parsed as an empty statement"

Fix #6351
Fix #6553 (Closed as duplicate)
Fix #5128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants