diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart index 40c42a8a3d7..652e463168b 100644 --- a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart +++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart @@ -6113,6 +6113,17 @@ Message _withArgumentsInvalidContinueTarget(String name) { arguments: {'name': name}); } +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code 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 templateInvalidGetterSetterTypeFieldContext = @@ -6438,11 +6449,34 @@ Message _withArgumentsInvalidTypeVariableVariancePositionInReturnType( } // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -const Code codeInvalidUnicodeEscape = messageInvalidUnicodeEscape; +const Code 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 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 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 '}'."""); diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/quote.dart b/pkg/_fe_analyzer_shared/lib/src/parser/quote.dart index c9ec28a5be9..fe146ce046a 100644 --- a/pkg/_fe_analyzer_shared/lib/src/parser/quote.dart +++ b/pkg/_fe_analyzer_shared/lib/src/parser/quote.dart @@ -193,8 +193,9 @@ String unescapeCodeUnits(List 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 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); diff --git a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml index c3c7bc1b4f4..41043e5773a 100644 --- a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml +++ b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml @@ -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 diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart index b28918d4bbf..19f32cc2d1c 100644 --- a/pkg/analyzer/lib/error/error.dart +++ b/pkg/analyzer/lib/error/error.dart @@ -805,7 +805,10 @@ const List 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, diff --git a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart index 1b0f41cf5b8..41bb5507e3f 100644 --- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart +++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart @@ -52,7 +52,7 @@ final fastaAnalyzerErrorCodes = [ 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 = [ 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 '}'.", ); diff --git a/pkg/analyzer/test/generated/error_parser_test.dart b/pkg/analyzer/test/generated/error_parser_test.dart index 139bb79b0e1..a8779b35d2a 100644 --- a/pkg/analyzer/test/generated/error_parser_test.dart +++ b/pkg/analyzer/test/generated/error_parser_test.dart @@ -1705,43 +1705,64 @@ class Wrong { 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() { diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml index 730af31f6be..0fcd0f7c52a 100644 --- a/pkg/front_end/messages.yaml +++ b/pkg/front_end/messages.yaml @@ -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 ({})." diff --git a/pkg/front_end/test/fasta/messages_suite.dart b/pkg/front_end/test/fasta/messages_suite.dart index df8fbb55cac..6b0ae9ad5dd 100644 --- a/pkg/front_end/test/fasta/messages_suite.dart +++ b/pkg/front_end/test/fasta/messages_suite.dart @@ -844,8 +844,11 @@ class Compile extends Step { } 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)); } } diff --git a/pkg/front_end/test/spell_checking_list_code.txt b/pkg/front_end/test/spell_checking_list_code.txt index 0093dcee802..ac64436f380 100644 --- a/pkg/front_end/test/spell_checking_list_code.txt +++ b/pkg/front_end/test/spell_checking_list_code.txt @@ -22,6 +22,7 @@ acon acov across activated +actively adequate adi advantage @@ -1363,6 +1364,7 @@ unconditionally unconstrained undeclare undergo +undermine undo undoable unequal diff --git a/pkg/front_end/test/spell_checking_list_messages.txt b/pkg/front_end/test/spell_checking_list_messages.txt index 664608e47db..329dc17c488 100644 --- a/pkg/front_end/test/spell_checking_list_messages.txt +++ b/pkg/front_end/test/spell_checking_list_messages.txt @@ -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 diff --git a/pkg/front_end/testcases/rasta/bad_unicode.dart.weak.expect b/pkg/front_end/testcases/rasta/bad_unicode.dart.weak.expect index 749bacec393..5c448ec8970 100644 --- a/pkg/front_end/testcases/rasta/bad_unicode.dart.weak.expect +++ b/pkg/front_end/testcases/rasta/bad_unicode.dart.weak.expect @@ -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. // ^^^^ // diff --git a/pkg/front_end/testcases/rasta/bad_unicode.dart.weak.modular.expect b/pkg/front_end/testcases/rasta/bad_unicode.dart.weak.modular.expect index 749bacec393..5c448ec8970 100644 --- a/pkg/front_end/testcases/rasta/bad_unicode.dart.weak.modular.expect +++ b/pkg/front_end/testcases/rasta/bad_unicode.dart.weak.modular.expect @@ -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. // ^^^^ // diff --git a/pkg/front_end/testcases/rasta/bad_unicode.dart.weak.transformed.expect b/pkg/front_end/testcases/rasta/bad_unicode.dart.weak.transformed.expect index 749bacec393..5c448ec8970 100644 --- a/pkg/front_end/testcases/rasta/bad_unicode.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/rasta/bad_unicode.dart.weak.transformed.expect @@ -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. // ^^^^ // diff --git a/tests/language/string/escape4_test.dart b/tests/language/string/escape4_test.dart index 6f4efba9469..0f2a6cbaeb6 100644 --- a/tests/language/string/escape4_test.dart +++ b/tests/language/string/escape4_test.dart @@ -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 diff --git a/tests/language/string/unicode1_test.dart b/tests/language/string/unicode1_test.dart index 04a9f5f2428..bf87c763040 100644 --- a/tests/language/string/unicode1_test.dart +++ b/tests/language/string/unicode1_test.dart @@ -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. } diff --git a/tests/language/string/unicode2_test.dart b/tests/language/string/unicode2_test.dart index 4624fbd33b2..ace2a0feb1d 100644 --- a/tests/language/string/unicode2_test.dart +++ b/tests/language/string/unicode2_test.dart @@ -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 '}'. } diff --git a/tests/language_2/string/escape4_test.dart b/tests/language_2/string/escape4_test.dart index fb83da25063..cfedc5d26ee 100644 --- a/tests/language_2/string/escape4_test.dart +++ b/tests/language_2/string/escape4_test.dart @@ -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 diff --git a/tests/language_2/string/unicode1_test.dart b/tests/language_2/string/unicode1_test.dart index 58b39bdc305..78443308648 100644 --- a/tests/language_2/string/unicode1_test.dart +++ b/tests/language_2/string/unicode1_test.dart @@ -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. } diff --git a/tests/language_2/string/unicode2_test.dart b/tests/language_2/string/unicode2_test.dart index 042b64209cd..6c2cb90e099 100644 --- a/tests/language_2/string/unicode2_test.dart +++ b/tests/language_2/string/unicode2_test.dart @@ -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 '}'. }