Ignore:
Timestamp:
Jun 17, 2014, 3:29:56 PM (11 years ago)
Author:
[email protected]
Message:

Fix error messages for incorrect hex literals
https://bugs.webkit.org/show_bug.cgi?id=133998

Reviewed by Mark Lam.

Source/JavaScriptCore:
Ensure that the error messages for bogus hex literals actually
make sense.

  • parser/Lexer.cpp:

(JSC::Lexer<T>::lex):

  • parser/ParserTokens.h:

LayoutTests:
Update tests for sane error messages.

  • sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T1-expected.txt:
  • sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T2-expected.txt:
  • sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T1-expected.txt:
  • sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T2-expected.txt:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r167313 r170079  
    16471647    case CharacterZero:
    16481648        shift();
    1649         if ((m_current | 0x20) == 'x' && isASCIIHexDigit(peek(1))) {
     1649        if ((m_current | 0x20) == 'x') {
     1650            if (!isASCIIHexDigit(peek(1))) {
     1651                m_lexErrorMessage = "No hexadecimal digits after '0x'";
     1652                token = INVALID_HEX_NUMBER_ERRORTOK;
     1653                goto returnError;
     1654            }
    16501655            parseHex(tokenData->doubleValue);
     1656            if (isIdentStart(m_current)) {
     1657                m_lexErrorMessage = "No space between hexadecimal literal and identifier";
     1658                token = INVALID_HEX_NUMBER_ERRORTOK;
     1659                goto returnError;
     1660            }
    16511661            token = NUMBER;
    1652         } else {
    1653             record8('0');
    1654             if (isASCIIOctalDigit(m_current)) {
    1655                 if (parseOctal(tokenData->doubleValue)) {
    1656                     if (strictMode) {
    1657                         m_lexErrorMessage = "Octal escapes are forbidden in strict mode";
    1658                         token = INVALID_OCTAL_NUMBER_ERRORTOK;
    1659                         goto returnError;
    1660                     }
    1661                     token = NUMBER;
     1662            m_buffer8.resize(0);
     1663            break;
     1664        }
     1665
     1666        record8('0');
     1667        if (isASCIIOctalDigit(m_current)) {
     1668            if (parseOctal(tokenData->doubleValue)) {
     1669                if (strictMode) {
     1670                    m_lexErrorMessage = "Octal escapes are forbidden in strict mode";
     1671                    token = INVALID_OCTAL_NUMBER_ERRORTOK;
     1672                    goto returnError;
    16621673                }
     1674                token = NUMBER;
    16631675            }
    16641676        }
Note: See TracChangeset for help on using the changeset viewer.