Attachment #8367486: patch v3 for bug #957513

View | Details | Raw Unified | Return to bug 957513
Collapse All | Expand All

(-)a/js/src/frontend/TokenStream.cpp (-11 / +7 lines)
Line     Link Here 
 Lines 1385-1414   TokenStream::getTokenInternal(Modifier m Link Here 
1385
                goto error;
1385
                goto error;
1386
            }
1386
            }
1387
            numStart = userbuf.addressOfNextRawChar() - 1;  // one past the '0o'
1387
            numStart = userbuf.addressOfNextRawChar() - 1;  // one past the '0o'
1388
            while ('0' <= c && c <= '7')
1388
            while ('0' <= c && c <= '7')
1389
                c = getCharIgnoreEOL();
1389
                c = getCharIgnoreEOL();
1390
        } else if (JS7_ISDEC(c)) {
1390
        } else if (JS7_ISDEC(c)) {
1391
            radix = 8;
1391
            radix = 8;
1392
            numStart = userbuf.addressOfNextRawChar() - 1;  // one past the '0'
1392
            numStart = userbuf.addressOfNextRawChar() - 1;  // one past the '0'
1393
1394
            // Octal integer literals are not permitted in strict mode code.
1395
            if (!reportStrictModeError(JSMSG_DEPRECATED_OCTAL))
1396
                goto error;
1397
1393
            while (JS7_ISDEC(c)) {
1398
            while (JS7_ISDEC(c)) {
1394
                // Octal integer literals are not permitted in strict mode code.
1399
                // Even in sloppy mode, 08 or 09 is a syntax error.
1395
                if (!reportStrictModeError(JSMSG_DEPRECATED_OCTAL))
1396
                    goto error;
1397
1398
                // Outside strict mode, we permit 08 and 09 as decimal numbers,
1399
                // which makes our behaviour a superset of the ECMA numeric
1400
                // grammar. We might not always be so permissive, so we warn
1401
                // about it.
1402
                if (c >= '8') {
1400
                if (c >= '8') {
1403
                    if (!reportWarning(JSMSG_BAD_OCTAL, c == '8' ? "08" : "09")) {
1401
                    if (!reportError(JSMSG_BAD_OCTAL, c == '8' ? "8" : "9"))
1404
                        goto error;
1402
                        goto error;
1405
                    }
1406
                    goto decimal;   // use the decimal scanner for the rest of the number
1407
                }
1403
                }
1408
                c = getCharIgnoreEOL();
1404
                c = getCharIgnoreEOL();
1409
            }
1405
            }
1410
        } else {
1406
        } else {
1411
            // '0' not followed by 'x', 'X' or a digit;  scan as a decimal number.
1407
            // '0' not followed by 'x', 'X' or a digit;  scan as a decimal number.
1412
            numStart = userbuf.addressOfNextRawChar() - 1;
1408
            numStart = userbuf.addressOfNextRawChar() - 1;
1413
            goto decimal;
1409
            goto decimal;
1414
        }
1410
        }
(-)a/js/src/jit-test/tests/parser/parseOctal.js (+8 lines)
Line     Link Here 
Line 0    Link Here 
1
load(libdir + 'asserts.js');
2
3
for (var code of ["08", "09", "01238", "01239", "08e+1"]) {
4
    assertThrowsInstanceOf(() => Function(code), SyntaxError);
5
    assertThrowsInstanceOf(() => eval(code), SyntaxError);
6
}
7
8
var ok = [0.8, 0.08, 0e8];
(-)a/js/src/js.msg (-1 / +1 lines)
Line     Link Here 
 Lines 190-206   MSG_DEF(JSMSG_MISSING_EXPONENT, 13 Link Here 
190
MSG_DEF(JSMSG_OUT_OF_MEMORY,          137, 0, JSEXN_ERR, "out of memory")
190
MSG_DEF(JSMSG_OUT_OF_MEMORY,          137, 0, JSEXN_ERR, "out of memory")
191
MSG_DEF(JSMSG_UNTERMINATED_STRING,    138, 0, JSEXN_SYNTAXERR, "unterminated string literal")
191
MSG_DEF(JSMSG_UNTERMINATED_STRING,    138, 0, JSEXN_SYNTAXERR, "unterminated string literal")
192
MSG_DEF(JSMSG_TOO_MANY_PARENS,        139, 0, JSEXN_INTERNALERR, "too many parentheses in regular expression")
192
MSG_DEF(JSMSG_TOO_MANY_PARENS,        139, 0, JSEXN_INTERNALERR, "too many parentheses in regular expression")
193
MSG_DEF(JSMSG_UNTERMINATED_COMMENT,   140, 0, JSEXN_SYNTAXERR, "unterminated comment")
193
MSG_DEF(JSMSG_UNTERMINATED_COMMENT,   140, 0, JSEXN_SYNTAXERR, "unterminated comment")
194
MSG_DEF(JSMSG_UNTERMINATED_REGEXP,    141, 0, JSEXN_SYNTAXERR, "unterminated regular expression literal")
194
MSG_DEF(JSMSG_UNTERMINATED_REGEXP,    141, 0, JSEXN_SYNTAXERR, "unterminated regular expression literal")
195
MSG_DEF(JSMSG_BAD_CLONE_FUNOBJ_SCOPE, 142, 0, JSEXN_TYPEERR, "bad cloned function scope chain")
195
MSG_DEF(JSMSG_BAD_CLONE_FUNOBJ_SCOPE, 142, 0, JSEXN_TYPEERR, "bad cloned function scope chain")
196
MSG_DEF(JSMSG_MISSING_OCTAL_DIGITS,   143, 0, JSEXN_SYNTAXERR, "missing octal digits after '0o'")
196
MSG_DEF(JSMSG_MISSING_OCTAL_DIGITS,   143, 0, JSEXN_SYNTAXERR, "missing octal digits after '0o'")
197
MSG_DEF(JSMSG_ILLEGAL_CHARACTER,      144, 0, JSEXN_SYNTAXERR, "illegal character")
197
MSG_DEF(JSMSG_ILLEGAL_CHARACTER,      144, 0, JSEXN_SYNTAXERR, "illegal character")
198
MSG_DEF(JSMSG_BAD_OCTAL,              145, 1, JSEXN_SYNTAXERR, "{0} is not a legal ECMA-262 octal constant")
198
MSG_DEF(JSMSG_BAD_OCTAL,              145, 1, JSEXN_SYNTAXERR, "numbers starting with 0 followed by a digit are octals and can't contain {0}")
199
MSG_DEF(JSMSG_RESULTING_STRING_TOO_LARGE, 146, 0, JSEXN_RANGEERR, "repeat count must be less than infinity and not overflow maximum string size")
199
MSG_DEF(JSMSG_RESULTING_STRING_TOO_LARGE, 146, 0, JSEXN_RANGEERR, "repeat count must be less than infinity and not overflow maximum string size")
200
MSG_DEF(JSMSG_UNCAUGHT_EXCEPTION,     147, 1, JSEXN_INTERNALERR, "uncaught exception: {0}")
200
MSG_DEF(JSMSG_UNCAUGHT_EXCEPTION,     147, 1, JSEXN_INTERNALERR, "uncaught exception: {0}")
201
MSG_DEF(JSMSG_INVALID_BACKREF,        148, 0, JSEXN_SYNTAXERR, "non-octal digit in an escape sequence that doesn't match a back-reference")
201
MSG_DEF(JSMSG_INVALID_BACKREF,        148, 0, JSEXN_SYNTAXERR, "non-octal digit in an escape sequence that doesn't match a back-reference")
202
MSG_DEF(JSMSG_BAD_BACKREF,            149, 0, JSEXN_SYNTAXERR, "back-reference exceeds number of capturing parentheses")
202
MSG_DEF(JSMSG_BAD_BACKREF,            149, 0, JSEXN_SYNTAXERR, "back-reference exceeds number of capturing parentheses")
203
MSG_DEF(JSMSG_PRECISION_RANGE,        150, 1, JSEXN_RANGEERR, "precision {0} out of range")
203
MSG_DEF(JSMSG_PRECISION_RANGE,        150, 1, JSEXN_RANGEERR, "precision {0} out of range")
204
MSG_DEF(JSMSG_BAD_GETTER_OR_SETTER,   151, 1, JSEXN_TYPEERR, "invalid {0} usage")
204
MSG_DEF(JSMSG_BAD_GETTER_OR_SETTER,   151, 1, JSEXN_TYPEERR, "invalid {0} usage")
205
MSG_DEF(JSMSG_BAD_ARRAY_LENGTH,       152, 0, JSEXN_RANGEERR, "invalid array length")
205
MSG_DEF(JSMSG_BAD_ARRAY_LENGTH,       152, 0, JSEXN_RANGEERR, "invalid array length")
206
MSG_DEF(JSMSG_CANT_DESCRIBE_PROPS,    153, 1, JSEXN_TYPEERR, "can't describe non-native properties of class {0}")
206
MSG_DEF(JSMSG_CANT_DESCRIBE_PROPS,    153, 1, JSEXN_TYPEERR, "can't describe non-native properties of class {0}")

Return to bug 957513