[Webkit-unassigned] [Bug 41844] New: JavaScript parser violates ECMA automatic semicolon insertion rule
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Thu Jul 8 02:51:44 PDT 2010
https://bugs.webkit.org/show_bug.cgi?id=41844
Summary: JavaScript parser violates ECMA automatic semicolon
insertion rule
Product: WebKit
Version: 528+ (Nightly build)
Platform: PC
OS/Version: All
Status: NEW
Severity: Normal
Priority: P2
Component: JavaScriptCore
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: kent.hansen at nokia.com
The following snippet:
JSGlobalContextRef context = JSGlobalContextCreateInGroup(NULL, NULL);
const char *script = "if (0)";
JSValueRef val = JSEvaluateScript(context, JSStringCreateWithUTF8CString(script), NULL, NULL, 1, NULL);
JSStringRef str = JSValueToStringCopy(context, val, NULL);
char buf[256];
JSStringGetUTF8CString(str, buf, 256);
printf("%s\n", buf);
prints "undefined".
ECMA-262 5th ed, section 7.9.1 "Rules of automatic semicolon", states: "When, as the program is parsed from left to right, the end of the input stream of tokens is encountered and the parser is unable to parse the input token stream as a single complete ECMAScript Program, then a semicolon is automatically inserted at the end of the input stream."
So far, so good.
But then the above is followed by: "However, there is an additional overriding condition on the preceding rules: a semicolon is never inserted automatically if the semicolon would then be parsed as an empty statement [...]."
When the program is "if (0)", as in the above snippet, per the above rule, a semicolon should _not_ automatically be inserted. Instead a SyntaxError should be thrown.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list