[parser-ish] Better errors on invalid unicode escapes

https://github.com/dart-lang/sdk/issues/48542

Change-Id: Icbdcc939a93c737914091c00aaefa3c4efb2dde0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237364
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
Jens Johansen
2022-03-17 13:57:45 +00:00
committed by Commit Bot
parent 29d0fe90e4
commit fd4e41a7af
19 changed files with 238 additions and 83 deletions
@@ -6113,6 +6113,17 @@ Message _withArgumentsInvalidContinueTarget(String name) {
arguments: {'name': name});
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeInvalidEscapeStarted = messageInvalidEscapeStarted;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageInvalidEscapeStarted = const MessageCode(
"InvalidEscapeStarted",
index: 126,
problemMessage: r"""The string '\' can't stand alone.""",
correctionMessage:
r"""Try adding another backslash (\) to escape the '\'.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<Message Function(String name)>
templateInvalidGetterSetterTypeFieldContext =
@@ -6438,11 +6449,34 @@ Message _withArgumentsInvalidTypeVariableVariancePositionInReturnType(
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeInvalidUnicodeEscape = messageInvalidUnicodeEscape;
const Code<Null> codeInvalidUnicodeEscapeUBracket =
messageInvalidUnicodeEscapeUBracket;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageInvalidUnicodeEscape = const MessageCode(
"InvalidUnicodeEscape",
const MessageCode messageInvalidUnicodeEscapeUBracket = const MessageCode(
"InvalidUnicodeEscapeUBracket",
index: 125,
problemMessage:
r"""An escape sequence starting with '\u{' must be followed by 1 to 6 hexadecimal digits followed by a '}'.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeInvalidUnicodeEscapeUNoBracket =
messageInvalidUnicodeEscapeUNoBracket;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageInvalidUnicodeEscapeUNoBracket = const MessageCode(
"InvalidUnicodeEscapeUNoBracket",
index: 124,
problemMessage:
r"""An escape sequence starting with '\u' must be followed by 4 hexadecimal digits.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeInvalidUnicodeEscapeUStarted =
messageInvalidUnicodeEscapeUStarted;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageInvalidUnicodeEscapeUStarted = const MessageCode(
"InvalidUnicodeEscapeUStarted",
index: 38,
problemMessage:
r"""An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.""");
@@ -193,8 +193,9 @@ String unescapeCodeUnits(List<int> codeUnits, bool isRaw, Object location,
code = $LF;
} else if (!isRaw && code == $BACKSLASH) {
if (codeUnits.length == ++i) {
// This should only be reachable in error cases.
listener.handleUnescapeError(
codes.messageInvalidUnicodeEscape, location, i, /* length = */ 1);
codes.messageInvalidEscapeStarted, location, i, /* length = */ 1);
return new String.fromCharCodes(codeUnits);
}
code = codeUnits[i];
@@ -240,47 +241,78 @@ String unescapeCodeUnits(List<int> codeUnits, bool isRaw, Object location,
} else if (code == $u) {
int begin = i;
if (codeUnits.length == i + 1) {
listener.handleUnescapeError(codes.messageInvalidUnicodeEscape,
location, begin, codeUnits.length + 1 - begin);
listener.handleUnescapeError(
codes.messageInvalidUnicodeEscapeUStarted,
location,
begin,
codeUnits.length + 1 - begin);
return new String.fromCharCodes(codeUnits);
}
code = codeUnits[i + 1];
bool foundEndBracket = false;
if (code == $OPEN_CURLY_BRACKET) {
// Expect 1-6 hex digits followed by '}'.
if (codeUnits.length == ++i) {
listener.handleUnescapeError(codes.messageInvalidUnicodeEscape,
location, begin, i + 1 - begin);
listener.handleUnescapeError(
codes.messageInvalidUnicodeEscapeUBracket,
location,
begin,
i + 1 - begin);
return new String.fromCharCodes(codeUnits);
}
code = 0;
for (int j = 0; j < 7; j++) {
if (codeUnits.length == ++i) {
listener.handleUnescapeError(codes.messageInvalidUnicodeEscape,
location, begin, i + 1 - begin);
listener.handleUnescapeError(
codes.messageInvalidUnicodeEscapeUBracket,
location,
begin,
i + 1 - begin);
return new String.fromCharCodes(codeUnits);
}
int digit = codeUnits[i];
if (j != 0 && digit == $CLOSE_CURLY_BRACKET) break;
if (j != 0 && digit == $CLOSE_CURLY_BRACKET) {
foundEndBracket = true;
break;
} else if (j == 6) {
break;
}
if (!isHexDigit(digit)) {
listener.handleUnescapeError(codes.messageInvalidUnicodeEscape,
location, begin, i + 2 - begin);
listener.handleUnescapeError(
codes.messageInvalidUnicodeEscapeUBracket,
location,
begin,
i + 2 - begin);
return new String.fromCharCodes(codeUnits);
}
code = (code << 4) + hexDigitValue(digit);
}
if (!foundEndBracket) {
listener.handleUnescapeError(
codes.messageInvalidUnicodeEscapeUBracket,
location,
begin,
i + 1 - begin);
}
} else {
// Expect exactly 4 hex digits.
if (codeUnits.length <= i + 4) {
listener.handleUnescapeError(codes.messageInvalidUnicodeEscape,
location, begin, codeUnits.length + 1 - begin);
listener.handleUnescapeError(
codes.messageInvalidUnicodeEscapeUNoBracket,
location,
begin,
codeUnits.length + 1 - begin);
return new String.fromCharCodes(codeUnits);
}
code = 0;
for (int j = 0; j < 4; j++) {
int digit = codeUnits[++i];
if (!isHexDigit(digit)) {
listener.handleUnescapeError(codes.messageInvalidUnicodeEscape,
location, begin, i + 1 - begin);
listener.handleUnescapeError(
codes.messageInvalidUnicodeEscapeUNoBracket,
location,
begin,
i + 1 - begin);
return new String.fromCharCodes(codeUnits);
}
code = (code << 4) + hexDigitValue(digit);
@@ -2096,7 +2096,13 @@ ParserErrorCode.INVALID_SYNC:
status: needsEvaluation
ParserErrorCode.INVALID_THIS_IN_INITIALIZER:
status: needsEvaluation
ParserErrorCode.INVALID_UNICODE_ESCAPE:
ParserErrorCode.INVALID_UNICODE_ESCAPE_STARTED:
status: needsEvaluation
ParserErrorCode.INVALID_UNICODE_ESCAPE_U_BRACKET:
status: needsEvaluation
ParserErrorCode.INVALID_UNICODE_ESCAPE_U_NO_BRACKET:
status: needsEvaluation
ParserErrorCode.INVALID_UNICODE_ESCAPE_U_STARTED:
status: needsEvaluation
ParserErrorCode.INVALID_USE_OF_COVARIANT_IN_EXTENSION:
status: needsEvaluation
+4 -1
View File
@@ -805,7 +805,10 @@ const List<ErrorCode> errorCodeValues = [
ParserErrorCode.INVALID_SUPER_IN_INITIALIZER,
ParserErrorCode.INVALID_SYNC,
ParserErrorCode.INVALID_THIS_IN_INITIALIZER,
ParserErrorCode.INVALID_UNICODE_ESCAPE,
ParserErrorCode.INVALID_UNICODE_ESCAPE_STARTED,
ParserErrorCode.INVALID_UNICODE_ESCAPE_U_BRACKET,
ParserErrorCode.INVALID_UNICODE_ESCAPE_U_NO_BRACKET,
ParserErrorCode.INVALID_UNICODE_ESCAPE_U_STARTED,
ParserErrorCode.INVALID_USE_OF_COVARIANT_IN_EXTENSION,
ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST,
ParserErrorCode.LITERAL_WITH_CLASS_AND_NEW,
@@ -52,7 +52,7 @@ final fastaAnalyzerErrorCodes = <ErrorCode?>[
ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR,
ParserErrorCode.MISSING_INITIALIZER,
ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST,
ParserErrorCode.INVALID_UNICODE_ESCAPE,
ParserErrorCode.INVALID_UNICODE_ESCAPE_U_STARTED,
ParserErrorCode.INVALID_OPERATOR,
ParserErrorCode.INVALID_HEX_ESCAPE,
ParserErrorCode.EXPECTED_INSTEAD,
@@ -138,6 +138,9 @@ final fastaAnalyzerErrorCodes = <ErrorCode?>[
ParserErrorCode.MULTIPLE_CLAUSES,
ParserErrorCode.OUT_OF_ORDER_CLAUSES,
ParserErrorCode.UNEXPECTED_TOKENS,
ParserErrorCode.INVALID_UNICODE_ESCAPE_U_NO_BRACKET,
ParserErrorCode.INVALID_UNICODE_ESCAPE_U_BRACKET,
ParserErrorCode.INVALID_UNICODE_ESCAPE_STARTED,
];
class ParserErrorCode extends ErrorCode {
@@ -1018,8 +1021,29 @@ class ParserErrorCode extends ErrorCode {
"'this.namedConstructor())",
);
static const ParserErrorCode INVALID_UNICODE_ESCAPE = ParserErrorCode(
'INVALID_UNICODE_ESCAPE',
static const ParserErrorCode INVALID_UNICODE_ESCAPE_STARTED = ParserErrorCode(
'INVALID_UNICODE_ESCAPE_STARTED',
"The string '\\' can't stand alone.",
correctionMessage: "Try adding another backslash (\\) to escape the '\\'.",
);
static const ParserErrorCode INVALID_UNICODE_ESCAPE_U_BRACKET =
ParserErrorCode(
'INVALID_UNICODE_ESCAPE_U_BRACKET',
"An escape sequence starting with '\\u{' must be followed by 1 to 6 "
"hexadecimal digits followed by a '}'.",
);
static const ParserErrorCode INVALID_UNICODE_ESCAPE_U_NO_BRACKET =
ParserErrorCode(
'INVALID_UNICODE_ESCAPE_U_NO_BRACKET',
"An escape sequence starting with '\\u' must be followed by 4 hexadecimal "
"digits.",
);
static const ParserErrorCode INVALID_UNICODE_ESCAPE_U_STARTED =
ParserErrorCode(
'INVALID_UNICODE_ESCAPE_U_STARTED',
"An escape sequence starting with '\\u' must be followed by 4 hexadecimal "
"digits or from 1 to 6 digits between '{' and '}'.",
);
@@ -1705,43 +1705,64 @@ class Wrong<T> {
void test_invalidUnicodeEscape_incomplete_noDigits() {
Expression expression = parseStringLiteral("'\\u{'");
expectNotNullIfNoErrors(expression);
listener.assertErrors(
[expectedError(ParserErrorCode.INVALID_UNICODE_ESCAPE, 1, 3)]);
listener.assertErrors([
expectedError(ParserErrorCode.INVALID_UNICODE_ESCAPE_U_BRACKET, 1, 3)
]);
}
void test_invalidUnicodeEscape_incomplete_noDigits_noBracket() {
Expression expression = parseStringLiteral("'\\u'");
expectNotNullIfNoErrors(expression);
listener.assertErrors([
expectedError(ParserErrorCode.INVALID_UNICODE_ESCAPE_U_STARTED, 1, 2)
]);
}
void test_invalidUnicodeEscape_incomplete_someDigits() {
Expression expression = parseStringLiteral("'\\u{0A'");
expectNotNullIfNoErrors(expression);
listener.assertErrors(
[expectedError(ParserErrorCode.INVALID_UNICODE_ESCAPE, 1, 5)]);
listener.assertErrors([
expectedError(ParserErrorCode.INVALID_UNICODE_ESCAPE_U_BRACKET, 1, 5)
]);
}
void test_invalidUnicodeEscape_invalidDigit() {
Expression expression = parseStringLiteral("'\\u0 and some more'");
expectNotNullIfNoErrors(expression);
listener.assertErrors([
expectedError(ParserErrorCode.INVALID_UNICODE_ESCAPE_U_NO_BRACKET, 1, 3)
]);
}
void test_invalidUnicodeEscape_too_high_number_variable() {
Expression expression = parseStringLiteral("'\\u{110000}'");
expectNotNullIfNoErrors(expression);
listener.assertErrors(
[expectedError(ParserErrorCode.INVALID_UNICODE_ESCAPE, 1, 3)]);
[expectedError(ParserErrorCode.INVALID_CODE_POINT, 1, 9)]);
}
void test_invalidUnicodeEscape_tooFewDigits_fixed() {
Expression expression = parseStringLiteral("'\\u04'");
expectNotNullIfNoErrors(expression);
listener.assertErrors(
[expectedError(ParserErrorCode.INVALID_UNICODE_ESCAPE, 1, 4)]);
listener.assertErrors([
expectedError(ParserErrorCode.INVALID_UNICODE_ESCAPE_U_NO_BRACKET, 1, 4)
]);
}
void test_invalidUnicodeEscape_tooFewDigits_variable() {
Expression expression = parseStringLiteral("'\\u{}'");
expectNotNullIfNoErrors(expression);
listener.assertErrors(
[expectedError(ParserErrorCode.INVALID_UNICODE_ESCAPE, 1, 4)]);
listener.assertErrors([
expectedError(ParserErrorCode.INVALID_UNICODE_ESCAPE_U_BRACKET, 1, 4)
]);
}
void test_invalidUnicodeEscape_tooManyDigits_variable() {
Expression expression = parseStringLiteral("'\\u{12345678}'");
Expression expression = parseStringLiteral("'\\u{0000000001}'");
expectNotNullIfNoErrors(expression);
listener.assertErrors(
[expectedError(ParserErrorCode.INVALID_CODE_POINT, 1, 9)]);
listener.assertErrors([
expectedError(ParserErrorCode.INVALID_UNICODE_ESCAPE_U_BRACKET, 1, 9)
]);
}
void test_libraryDirectiveNotFirst() {
+26 -2
View File
@@ -1308,16 +1308,40 @@ InvalidHexEscape:
- "'\\x0'"
- "'\\x0y'"
InvalidUnicodeEscape:
InvalidUnicodeEscapeUStarted:
index: 38
problemMessage: "An escape sequence starting with '\\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'."
analyzerCode: ParserErrorCode.INVALID_UNICODE_ESCAPE
analyzerCode: ParserErrorCode.INVALID_UNICODE_ESCAPE_U_STARTED
expression:
- "'\\u'"
InvalidUnicodeEscapeUNoBracket:
index: 124
problemMessage: "An escape sequence starting with '\\u' must be followed by 4 hexadecimal digits."
analyzerCode: ParserErrorCode.INVALID_UNICODE_ESCAPE_U_NO_BRACKET
expression:
- "'\\u0F'"
InvalidUnicodeEscapeUBracket:
index: 125
problemMessage: "An escape sequence starting with '\\u{' must be followed by 1 to 6 hexadecimal digits followed by a '}'."
analyzerCode: ParserErrorCode.INVALID_UNICODE_ESCAPE_U_BRACKET
expression:
- "'\\u{'"
- "'\\u{03'"
- "'\\u{0Z}'"
- "'\\u{0000003}'"
InvalidEscapeStarted:
index: 126
problemMessage: "The string '\\' can't stand alone."
correctionMessage: "Try adding another backslash (\\) to escape the '\\'."
analyzerCode: ParserErrorCode.INVALID_UNICODE_ESCAPE_STARTED
exampleAllowMoreCodes: true
expression:
- |
print('Hello, World!\
');
UnexpectedDollarInString:
problemMessage: "A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({})."
+5 -2
View File
@@ -844,8 +844,11 @@ class Compile extends Step<Example?, Null, MessageTestSuite> {
}
return fail(
null,
suite.formatProblems("Too many messages reported in ${example.name}:",
example, messages));
suite.formatProblems(
"Too many or unexpected messages (${messages.length}) reported "
"in ${example.name}:",
example,
messages));
}
}
@@ -22,6 +22,7 @@ acon
acov
across
activated
actively
adequate
adi
advantage
@@ -1363,6 +1364,7 @@ unconditionally
unconstrained
undeclare
undergo
undermine
undo
undoable
unequal
@@ -50,6 +50,7 @@ list.filled
loadlibrary
macro
migrate
n
name.#name
name.stack
nameokempty
@@ -68,11 +69,13 @@ part(s)
patch(es)
placing
pubspec.yaml
r
re
sdksummary
size
solutions
stacktrace
stand
staticinterop
stringokempty
struct<#name
@@ -80,6 +83,7 @@ structs
super.namedconstructor
superinterface
supermixin
t
team
this.namedconstructor
this.x
@@ -2,7 +2,7 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/rasta/bad_unicode.dart:6:10: Error: An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.
// pkg/front_end/testcases/rasta/bad_unicode.dart:6:10: Error: An escape sequence starting with '\u' must be followed by 4 hexadecimal digits.
// print("\u00"); // Bad Unicode escape, must have 4 hex digits.
// ^^^^
//
@@ -2,7 +2,7 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/rasta/bad_unicode.dart:6:10: Error: An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.
// pkg/front_end/testcases/rasta/bad_unicode.dart:6:10: Error: An escape sequence starting with '\u' must be followed by 4 hexadecimal digits.
// print("\u00"); // Bad Unicode escape, must have 4 hex digits.
// ^^^^
//
@@ -2,7 +2,7 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/rasta/bad_unicode.dart:6:10: Error: An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.
// pkg/front_end/testcases/rasta/bad_unicode.dart:6:10: Error: An escape sequence starting with '\u' must be followed by 4 hexadecimal digits.
// print("\u00"); // Bad Unicode escape, must have 4 hex digits.
// ^^^^
//
+11 -13
View File
@@ -9,23 +9,21 @@ main() {
// static error updater tool, so if you need to tweak the static error
// expectations in this test, you may need to do so manually.
print('Hello, World!\
// ^
// [cfe] Can't find ')' to match '('.
// ^
// [cfe] String starting with ' must end with '.
// ^
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE_STARTED
// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
// [cfe] The string '\' can't stand alone.
');
// [error line 11, column 8, length 1]
// [cfe] Can't find ')' to match '('.
// [error line 11, column 9, length 1]
// [cfe] String starting with ' must end with '.
// [error line 11, column 23, length 1]
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.
// [error line 11, column 23, length 1]
// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
// [error line 12, column 1, length 3]
// [error column 1, length 3]
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
// [cfe] Expected ';' after this.
// [error line 12, column 1]
// [cfe] String starting with ' must end with '.
// [error line 12, column 3, length 1]
//^
// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
}
// [error line 29, column 1, length 1]
// [error column 1, length 1]
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+4 -4
View File
@@ -7,10 +7,10 @@
main() {
var str = "Foo\u00";
// ^^^^
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE_U_NO_BRACKET
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits.
str = "Foo\uDEEMBar";
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE_U_NO_BRACKET
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits.
}
+7 -4
View File
@@ -7,11 +7,14 @@
main() {
var str = "Foo\u{}Bar";
// ^^^^
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE_U_BRACKET
// [cfe] An escape sequence starting with '\u{' must be followed by 1 to 6 hexadecimal digits followed by a '}'.
str = "Foo\u{000000000}Bar";
// ^^^^^^^^^
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE_U_BRACKET
// [cfe] An escape sequence starting with '\u{' must be followed by 1 to 6 hexadecimal digits followed by a '}'.
str = "Foo\u{DEAF!}Bar";
// ^^^^^^^^
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE_U_BRACKET
// [cfe] An escape sequence starting with '\u{' must be followed by 1 to 6 hexadecimal digits followed by a '}'.
}
+11 -13
View File
@@ -11,23 +11,21 @@ main() {
// static error updater tool, so if you need to tweak the static error
// expectations in this test, you may need to do so manually.
print('Hello, World!\
// ^
// [cfe] Can't find ')' to match '('.
// ^
// [cfe] String starting with ' must end with '.
// ^
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE_STARTED
// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
// [cfe] The string '\' can't stand alone.
');
// [error line 13, column 8, length 1]
// [cfe] Can't find ')' to match '('.
// [error line 13, column 9, length 1]
// [cfe] String starting with ' must end with '.
// [error line 13, column 23, length 1]
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.
// [error line 13, column 23, length 1]
// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
// [error line 14, column 1, length 3]
// [error column 1, length 3]
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
// [cfe] Expected ';' after this.
// [error line 14, column 1]
// [cfe] String starting with ' must end with '.
// [error line 14, column 3, length 1]
//^
// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
}
// [error line 31, column 1, length 1]
// [error column 1, length 1]
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+4 -4
View File
@@ -9,10 +9,10 @@
main() {
var str = "Foo\u00";
// ^^^^
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE_U_NO_BRACKET
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits.
str = "Foo\uDEEMBar";
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE_U_NO_BRACKET
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits.
}
+7 -4
View File
@@ -9,11 +9,14 @@
main() {
var str = "Foo\u{}Bar";
// ^^^^
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE_U_BRACKET
// [cfe] An escape sequence starting with '\u{' must be followed by 1 to 6 hexadecimal digits followed by a '}'.
str = "Foo\u{000000000}Bar";
// ^^^^^^^^^
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE_U_BRACKET
// [cfe] An escape sequence starting with '\u{' must be followed by 1 to 6 hexadecimal digits followed by a '}'.
str = "Foo\u{DEAF!}Bar";
// ^^^^^^^^
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE
// [cfe] An escape sequence starting with '\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.
// [analyzer] SYNTACTIC_ERROR.INVALID_UNICODE_ESCAPE_U_BRACKET
// [cfe] An escape sequence starting with '\u{' must be followed by 1 to 6 hexadecimal digits followed by a '}'.
}