Diff
Modified: trunk/LayoutTests/ChangeLog (170078 => 170079)
--- trunk/LayoutTests/ChangeLog 2014-06-17 22:27:16 UTC (rev 170078)
+++ trunk/LayoutTests/ChangeLog 2014-06-17 22:29:56 UTC (rev 170079)
@@ -1,3 +1,17 @@
+2014-06-17 Oliver Hunt <[email protected]>
+
+ Fix error messages for incorrect hex literals
+ https://bugs.webkit.org/show_bug.cgi?id=133998
+
+ Reviewed by Mark Lam.
+
+ 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:
+
2014-06-17 Carlos Alberto Lopez Perez <[email protected]>
[GTK] Fix the handling of resize events after r169505.
Added: trunk/LayoutTests/js/parser-error-messages-expected.txt (0 => 170079)
--- trunk/LayoutTests/js/parser-error-messages-expected.txt (rev 0)
+++ trunk/LayoutTests/js/parser-error-messages-expected.txt 2014-06-17 22:29:56 UTC (rev 170079)
@@ -0,0 +1,14 @@
+Tests error messages to make sure that they're sane
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS parseTest('0x') is "No hexadecimal digits after '0x'"
+PASS parseTest('0xg') is "No hexadecimal digits after '0x'"
+PASS parseTest('0x1.2') is "Unexpected number '.2'. Parse error."
+PASS parseTest('0x1g') is "No space between hexadecimal literal and identifier"
+PASS parseTest('0x1in') is "No space between hexadecimal literal and identifier"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/js/parser-error-messages.html (0 => 170079)
--- trunk/LayoutTests/js/parser-error-messages.html (rev 0)
+++ trunk/LayoutTests/js/parser-error-messages.html 2014-06-17 22:29:56 UTC (rev 170079)
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/js/script-tests/parser-error-messages.js (0 => 170079)
--- trunk/LayoutTests/js/script-tests/parser-error-messages.js (rev 0)
+++ trunk/LayoutTests/js/script-tests/parser-error-messages.js 2014-06-17 22:29:56 UTC (rev 170079)
@@ -0,0 +1,17 @@
+description("Tests error messages to make sure that they're sane");
+
+function parseTest(source)
+{
+ try {
+ eval(source);
+ } catch (e) {
+ return e.message
+ }
+}
+
+shouldBe("parseTest('0x')", "\"No hexadecimal digits after '0x'\"");
+shouldBe("parseTest('0xg')", "\"No hexadecimal digits after '0x'\"");
+shouldBe("parseTest('0x1.2')", "\"Unexpected number '.2'. Parse error.\"");
+shouldBe("parseTest('0x1g')", "\"No space between hexadecimal literal and identifier\"");
+shouldBe("parseTest('0x1in')", "\"No space between hexadecimal literal and identifier\"");
+
Modified: trunk/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T1-expected.txt (170078 => 170079)
--- trunk/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T1-expected.txt 2014-06-17 22:27:16 UTC (rev 170078)
+++ trunk/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T1-expected.txt 2014-06-17 22:29:56 UTC (rev 170079)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: At least one digit must occur after a decimal point
+CONSOLE MESSAGE: line 77: SyntaxError: No hexadecimal digits after '0x'
S7.8.3_A6.1_T1
PASS Expected parsing failure
Modified: trunk/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T2-expected.txt (170078 => 170079)
--- trunk/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T2-expected.txt 2014-06-17 22:27:16 UTC (rev 170078)
+++ trunk/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T2-expected.txt 2014-06-17 22:29:56 UTC (rev 170079)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: At least one digit must occur after a decimal point
+CONSOLE MESSAGE: line 77: SyntaxError: No hexadecimal digits after '0x'
S7.8.3_A6.1_T2
PASS Expected parsing failure
Modified: trunk/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T1-expected.txt (170078 => 170079)
--- trunk/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T1-expected.txt 2014-06-17 22:27:16 UTC (rev 170078)
+++ trunk/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T1-expected.txt 2014-06-17 22:29:56 UTC (rev 170079)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: At least one digit must occur after a decimal point
+CONSOLE MESSAGE: line 77: SyntaxError: No hexadecimal digits after '0x'
S7.8.3_A6.2_T1
PASS Expected parsing failure
Modified: trunk/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T2-expected.txt (170078 => 170079)
--- trunk/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T2-expected.txt 2014-06-17 22:27:16 UTC (rev 170078)
+++ trunk/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T2-expected.txt 2014-06-17 22:29:56 UTC (rev 170079)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: At least one digit must occur after a decimal point
+CONSOLE MESSAGE: line 77: SyntaxError: No hexadecimal digits after '0x'
S7.8.3_A6.2_T2
PASS Expected parsing failure
Modified: trunk/Source/_javascript_Core/ChangeLog (170078 => 170079)
--- trunk/Source/_javascript_Core/ChangeLog 2014-06-17 22:27:16 UTC (rev 170078)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-06-17 22:29:56 UTC (rev 170079)
@@ -1,3 +1,17 @@
+2014-06-17 Oliver Hunt <[email protected]>
+
+ Fix error messages for incorrect hex literals
+ https://bugs.webkit.org/show_bug.cgi?id=133998
+
+ Reviewed by Mark Lam.
+
+ Ensure that the error messages for bogus hex literals actually
+ make sense.
+
+ * parser/Lexer.cpp:
+ (JSC::Lexer<T>::lex):
+ * parser/ParserTokens.h:
+
2014-06-17 Matthew Mirman <[email protected]>
Fixes bug where building JSC sometimes crashes at build-symbol-table-index.py. Also adds licenses.
Modified: trunk/Source/_javascript_Core/parser/Lexer.cpp (170078 => 170079)
--- trunk/Source/_javascript_Core/parser/Lexer.cpp 2014-06-17 22:27:16 UTC (rev 170078)
+++ trunk/Source/_javascript_Core/parser/Lexer.cpp 2014-06-17 22:29:56 UTC (rev 170079)
@@ -1646,20 +1646,32 @@
goto inNumberAfterDecimalPoint;
case CharacterZero:
shift();
- if ((m_current | 0x20) == 'x' && isASCIIHexDigit(peek(1))) {
+ if ((m_current | 0x20) == 'x') {
+ if (!isASCIIHexDigit(peek(1))) {
+ m_lexErrorMessage = "No hexadecimal digits after '0x'";
+ token = INVALID_HEX_NUMBER_ERRORTOK;
+ goto returnError;
+ }
parseHex(tokenData->doubleValue);
+ if (isIdentStart(m_current)) {
+ m_lexErrorMessage = "No space between hexadecimal literal and identifier";
+ token = INVALID_HEX_NUMBER_ERRORTOK;
+ goto returnError;
+ }
token = NUMBER;
- } else {
- record8('0');
- if (isASCIIOctalDigit(m_current)) {
- if (parseOctal(tokenData->doubleValue)) {
- if (strictMode) {
- m_lexErrorMessage = "Octal escapes are forbidden in strict mode";
- token = INVALID_OCTAL_NUMBER_ERRORTOK;
- goto returnError;
- }
- token = NUMBER;
+ m_buffer8.resize(0);
+ break;
+ }
+
+ record8('0');
+ if (isASCIIOctalDigit(m_current)) {
+ if (parseOctal(tokenData->doubleValue)) {
+ if (strictMode) {
+ m_lexErrorMessage = "Octal escapes are forbidden in strict mode";
+ token = INVALID_OCTAL_NUMBER_ERRORTOK;
+ goto returnError;
}
+ token = NUMBER;
}
}
FALLTHROUGH;
Modified: trunk/Source/_javascript_Core/parser/ParserTokens.h (170078 => 170079)
--- trunk/Source/_javascript_Core/parser/ParserTokens.h 2014-06-17 22:27:16 UTC (rev 170078)
+++ trunk/Source/_javascript_Core/parser/ParserTokens.h 2014-06-17 22:29:56 UTC (rev 170079)
@@ -149,7 +149,8 @@
INVALID_NUMERIC_LITERAL_ERRORTOK = 7 | ErrorTokenFlag,
UNTERMINATED_STRING_LITERAL_ERRORTOK = 8 | ErrorTokenFlag | UnterminatedErrorTokenFlag,
INVALID_STRING_LITERAL_ERRORTOK = 9 | ErrorTokenFlag,
- INVALID_PRIVATE_NAME_ERRORTOK = 10 | ErrorTokenFlag
+ INVALID_PRIVATE_NAME_ERRORTOK = 10 | ErrorTokenFlag,
+ INVALID_HEX_NUMBER_ERRORTOK = 11 | ErrorTokenFlag
};
struct JSTextPosition {