From 0590d1224028eb0b8abe320cca35f38385297a02 Mon Sep 17 00:00:00 2001
From: Marijn Haverbeke
Whether a single character denotes a newline.
var newline = /[\n\r\u2028\u2029]/;Matches a whole line break (where CRLF is considered a single -line break). Used to count lines.
var lineBreak = /\r\n?|[\n\r\u2028\u2029]/g;Test whether a given character code starts an identifier.
function isIdentifierStart(code) {
+line break). Used to count lines. var lineBreak = /\r\n|[\n\r\u2028\u2029]/g;Test whether a given character code starts an identifier.
function isIdentifierStart(code) {
return (code >= 65 && code <= 90) || (code >= 97 && code <= 122) ||
code === 36 || code === 95 ||
(code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)));
@@ -438,6 +438,7 @@ will return null unless the integer has exactly len di
var octal = /^[0-7]+/.exec(input.slice(tokPos, tokPos + 3));
if (octal) octal = octal[0];
while (octal && parseInt(octal, 8) > 255) octal = octal.slice(0, octal.length - 1);
+ if (octal === "0") octal = null;
++tokPos;
if (octal) {
if (strict) raise(tokPos - 2, "Octal literal in strict mode");
diff --git a/test/tests.js b/test/tests.js
index 4dbbe7fd73..a34b7698b2 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -25836,6 +25836,151 @@ test("foo: if (true) break foo;", {
]
});
+test("(function () { 'use strict'; '\0'; }())", {
+ type: "Program",
+ start: 0,
+ end: 38,
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ },
+ body: [
+ {
+ type: "ExpressionStatement",
+ start: 0,
+ end: 38,
+ loc: {
+ start: {
+ line: 1,
+ column: 0
+ },
+ end: {
+ line: 1,
+ column: 38
+ }
+ },
+ expression: {
+ type: "CallExpression",
+ start: 1,
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 37
+ }
+ },
+ callee: {
+ type: "FunctionExpression",
+ start: 1,
+ end: 35,
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ },
+ id: null,
+ params: [],
+ body: {
+ type: "BlockStatement",
+ start: 13,
+ end: 35,
+ loc: {
+ start: {
+ line: 1,
+ column: 13
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
+ },
+ body: [
+ {
+ type: "ExpressionStatement",
+ start: 15,
+ end: 28,
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 28
+ }
+ },
+ expression: {
+ type: "Literal",
+ start: 15,
+ end: 27,
+ loc: {
+ start: {
+ line: 1,
+ column: 15
+ },
+ end: {
+ line: 1,
+ column: 27
+ }
+ },
+ value: "use strict"
+ }
+ },
+ {
+ type: "ExpressionStatement",
+ start: 29,
+ end: 33,
+ loc: {
+ start: {
+ line: 1,
+ column: 29
+ },
+ end: {
+ line: 1,
+ column: 33
+ }
+ },
+ expression: {
+ type: "Literal",
+ start: 29,
+ end: 32,
+ loc: {
+ start: {
+ line: 1,
+ column: 29
+ },
+ end: {
+ line: 1,
+ column: 32
+ }
+ },
+ value: "\u0000"
+ }
+ }
+ ]
+ }
+ },
+ arguments: [],
+ end: 37
+ }
+ }
+ ]
+});
+
// Failure tests
testFail("{",