Changeset 247845 in webkit


Ignore:
Timestamp:
Jul 25, 2019 4:55:45 PM (5 years ago)
Author:
Ross Kirsling
Message:

Legacy numeric literals should not permit separators or BigInt
https://bugs.webkit.org/show_bug.cgi?id=199984

Reviewed by Keith Miller.

JSTests:

  • stress/big-int-literals.js:
  • stress/numeric-literal-separators.js:

Source/JavaScriptCore:

  • parser/Lexer.cpp:

(JSC::Lexer<T>::parseOctal):
(JSC::Lexer<T>::parseDecimal):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r247819 r247845  
     12019-07-25  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        Legacy numeric literals should not permit separators or BigInt
     4        https://bugs.webkit.org/show_bug.cgi?id=199984
     5
     6        Reviewed by Keith Miller.
     7
     8        * stress/big-int-literals.js:
     9        * stress/numeric-literal-separators.js:
     10
    1112019-07-25  Ross Kirsling  <ross.kirsling@sony.com>
    212
  • trunk/JSTests/stress/big-int-literals.js

    r245406 r247845  
    1717// Test 0 conversions
    1818let n = 0n;
    19 assert(n === 0n);
    20 
    21 n = 00n;
    2219assert(n === 0n);
    2320
     
    106103assertThrowSyntaxError("10E20n");
    107104assertThrowSyntaxError("--10n");
     105assertThrowSyntaxError("00n");
     106assertThrowSyntaxError("01n");
     107assertThrowSyntaxError("09n");
  • trunk/JSTests/stress/numeric-literal-separators.js

    r245655 r247845  
    9595shouldThrow('1e-2_', SyntaxError);
    9696shouldThrow('1e-2__2', SyntaxError);
     97
     98shouldThrow('01_1', SyntaxError);
     99shouldThrow('01_9', SyntaxError);
     100shouldThrow('09_1', SyntaxError);
     101shouldThrow('0100_001', SyntaxError);
     102shouldThrow('0100_009', SyntaxError);
     103shouldThrow('0900_001', SyntaxError);
     104shouldThrow('010000000000_1', SyntaxError);
     105shouldThrow('010000000000_9', SyntaxError);
     106shouldThrow('090000000000_1', SyntaxError);
  • trunk/Source/JavaScriptCore/ChangeLog

    r247844 r247845  
     12019-07-25  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        Legacy numeric literals should not permit separators or BigInt
     4        https://bugs.webkit.org/show_bug.cgi?id=199984
     5
     6        Reviewed by Keith Miller.
     7
     8        * parser/Lexer.cpp:
     9        (JSC::Lexer<T>::parseOctal):
     10        (JSC::Lexer<T>::parseDecimal):
     11
    1122019-07-25  Yusuke Suzuki  <ysuzuki@apple.com>
    213
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r247819 r247845  
    16261626{
    16271627    ASSERT(isASCIIOctalDigit(m_current));
     1628    ASSERT(!m_buffer8.size() || (m_buffer8.size() == 1 && m_buffer8[0] == '0'));
     1629    bool isLegacyLiteral = m_buffer8.size();
    16281630
    16291631    // Optimization: most octal values fit into 4 bytes.
     
    16371639    do {
    16381640        if (m_current == '_') {
    1639             if (UNLIKELY(!isASCIIOctalDigit(peek(1))))
     1641            if (UNLIKELY(!isASCIIOctalDigit(peek(1)) || isLegacyLiteral))
    16401642                return WTF::nullopt;
    16411643
     
    16571659    while (isASCIIOctalDigitOrSeparator(m_current)) {
    16581660        if (m_current == '_') {
    1659             if (UNLIKELY(!isASCIIOctalDigit(peek(1))))
     1661            if (UNLIKELY(!isASCIIOctalDigit(peek(1)) || isLegacyLiteral))
    16601662                return WTF::nullopt;
    16611663
     
    16671669    }
    16681670
    1669     if (UNLIKELY(Options::useBigInt() && m_current == 'n'))
     1671    if (UNLIKELY(Options::useBigInt() && m_current == 'n') && !isLegacyLiteral)
    16701672        return NumberParseResult { makeIdentifier(m_buffer8.data(), m_buffer8.size()) };
    16711673
     
    16801682{
    16811683    ASSERT(isASCIIDigit(m_current) || m_buffer8.size());
     1684    bool isLegacyLiteral = m_buffer8.size() && isASCIIDigitOrSeparator(m_current);
    16821685
    16831686    // Optimization: most decimal values fit into 4 bytes.
     
    16951698        do {
    16961699            if (m_current == '_') {
    1697                 if (UNLIKELY(!isASCIIDigit(peek(1))))
     1700                if (UNLIKELY(!isASCIIDigit(peek(1)) || isLegacyLiteral))
    16981701                    return WTF::nullopt;
    16991702
     
    17161719    while (isASCIIDigitOrSeparator(m_current)) {
    17171720        if (m_current == '_') {
    1718             if (UNLIKELY(!isASCIIDigit(peek(1))))
     1721            if (UNLIKELY(!isASCIIDigit(peek(1)) || isLegacyLiteral))
    17191722                return WTF::nullopt;
    17201723
     
    17261729    }
    17271730   
    1728     if (UNLIKELY(Options::useBigInt() && m_current == 'n'))
     1731    if (UNLIKELY(Options::useBigInt() && m_current == 'n' && !isLegacyLiteral))
    17291732        return NumberParseResult { makeIdentifier(m_buffer8.data(), m_buffer8.size()) };
    17301733
Note: See TracChangeset for help on using the changeset viewer.