Skip to content

Commit 34ed30f

Browse files
Dan Rubelcommit-bot@chromium.org
authored andcommitted
prepend unterminated string error code
Change-Id: I95884700f7a43abfb89753b7381167bac19e4c2b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110144 Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 24d1e51 commit 34ed30f

18 files changed

+89
-88
lines changed

pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,7 @@ abstract class AbstractScanner implements Scanner {
17661766
appendSyntheticSubstringToken(TokenType.STRING, start, asciiOnly, suffix);
17671767
// Ensure that the error is reported on a visible token
17681768
int errorStart = tokenStart < stringOffset ? tokenStart : quoteStart;
1769-
appendErrorToken(new UnterminatedString(prefix, errorStart, stringOffset));
1769+
prependErrorToken(new UnterminatedString(prefix, errorStart, stringOffset));
17701770
}
17711771

17721772
int advanceAfterError(bool shouldAdvance) {

pkg/front_end/lib/src/fasta/scanner/recover.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Token scannerRecovery(List<int> bytes, Token tokens, List<int> lineStarts) {
130130
}
131131

132132
recoverString() {
133-
return errorTail.next;
133+
throw "Internal error: String error token should have been prepended";
134134
}
135135

136136
recoverHexDigit() {
@@ -155,8 +155,9 @@ Token scannerRecovery(List<int> bytes, Token tokens, List<int> lineStarts) {
155155
// All unmatched error tokens should have been prepended
156156
Token current = tokens;
157157
while (current is ErrorToken &&
158-
(current.errorCode == codeUnmatchedToken ||
159-
current.errorCode == codeExpectedHexDigit)) {
158+
(current.errorCode == codeExpectedHexDigit ||
159+
current.errorCode == codeUnmatchedToken ||
160+
current.errorCode == codeUnterminatedString)) {
160161
if (errorTail == null) {
161162
error = current;
162163
}

pkg/front_end/test/scanner_fasta_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,13 @@ abstract class ScannerTest_Fasta_Base {
501501

502502
void test_string_simple_missing_interpolation_identifier() {
503503
Token token = scan(r'"foo $');
504-
expect((token as fasta.ErrorToken).errorCode,
505-
same(codeUnexpectedDollarInString));
506-
507-
token = token.next;
508504
expect((token as fasta.ErrorToken).errorCode, same(codeUnterminatedString));
509505
expect((token as fasta.UnterminatedString).start, '"');
510506

507+
token = token.next;
508+
expect((token as fasta.ErrorToken).errorCode,
509+
same(codeUnexpectedDollarInString));
510+
511511
token = token.next;
512512
expectToken(token, TokenType.STRING, 0, 5, lexeme: '"foo ');
513513

pkg/front_end/testcases/rasta/bad_interpolation.dart.legacy.expect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ library;
22
//
33
// Problems in library:
44
//
5-
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:8: Error: Can't find ')' to match '('.
6-
// print(" $x.);
7-
// ^
8-
//
95
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:13: Error: String starting with " must end with ".
106
// print(" $x.);
117
// ^^^
128
//
9+
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:8: Error: Can't find ')' to match '('.
10+
// print(" $x.);
11+
// ^
12+
//
1313
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:12: Warning: Getter not found: 'x'.
1414
// print(" $x.);
1515
// ^

pkg/front_end/testcases/rasta/bad_interpolation.dart.legacy.transformed.expect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ library;
22
//
33
// Problems in library:
44
//
5-
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:8: Error: Can't find ')' to match '('.
6-
// print(" $x.);
7-
// ^
8-
//
95
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:13: Error: String starting with " must end with ".
106
// print(" $x.);
117
// ^^^
128
//
9+
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:8: Error: Can't find ')' to match '('.
10+
// print(" $x.);
11+
// ^
12+
//
1313
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:12: Warning: Getter not found: 'x'.
1414
// print(" $x.);
1515
// ^

pkg/front_end/testcases/rasta/bad_interpolation.dart.outline.expect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ library;
22
//
33
// Problems in library:
44
//
5-
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:8: Error: Can't find ')' to match '('.
6-
// print(" $x.);
7-
// ^
8-
//
95
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:13: Error: String starting with " must end with ".
106
// print(" $x.);
117
// ^^^
128
//
9+
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:8: Error: Can't find ')' to match '('.
10+
// print(" $x.);
11+
// ^
12+
//
1313
import self as self;
1414

1515
static method main() → dynamic

pkg/front_end/testcases/rasta/bad_interpolation.dart.strong.expect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ library;
22
//
33
// Problems in library:
44
//
5-
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:8: Error: Can't find ')' to match '('.
6-
// print(" $x.);
7-
// ^
8-
//
95
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:13: Error: String starting with " must end with ".
106
// print(" $x.);
117
// ^^^
128
//
9+
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:8: Error: Can't find ')' to match '('.
10+
// print(" $x.);
11+
// ^
12+
//
1313
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:12: Error: Getter not found: 'x'.
1414
// print(" $x.);
1515
// ^

pkg/front_end/testcases/rasta/bad_interpolation.dart.strong.transformed.expect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ library;
22
//
33
// Problems in library:
44
//
5-
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:8: Error: Can't find ')' to match '('.
6-
// print(" $x.);
7-
// ^
8-
//
95
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:13: Error: String starting with " must end with ".
106
// print(" $x.);
117
// ^^^
128
//
9+
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:8: Error: Can't find ')' to match '('.
10+
// print(" $x.);
11+
// ^
12+
//
1313
// pkg/front_end/testcases/rasta/bad_interpolation.dart:6:12: Error: Getter not found: 'x'.
1414
// print(" $x.);
1515
// ^

pkg/front_end/testcases/regress/issue_29976.dart.legacy.expect

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ library;
22
//
33
// Problems in library:
44
//
5+
// pkg/front_end/testcases/regress/issue_29976.dart:9:15: Error: String starting with ' must end with '.
6+
// "x${x*"'"é'}x
7+
// ^^^
8+
//
59
// pkg/front_end/testcases/regress/issue_29976.dart:9:7: Error: Can't find '}' to match '${'.
610
// "x${x*"'"é'}x
711
// ^
812
//
13+
// pkg/front_end/testcases/regress/issue_29976.dart:9:5: Error: String starting with " must end with ".
14+
// "x${x*"'"é'}x
15+
// ^^^^^^^^^^^^^^...
16+
//
917
// pkg/front_end/testcases/regress/issue_29976.dart:9:14: Error: The non-ASCII character 'é' (U+00E9) can't be used in identifiers, only in strings and comments.
1018
// Try using an US-ASCII letter, a digit, '_' (an underscore), or '$' (a dollar sign).
1119
// "x${x*"'"é'}x
1220
// ^
1321
//
14-
// pkg/front_end/testcases/regress/issue_29976.dart:9:15: Error: String starting with ' must end with '.
15-
// "x${x*"'"é'}x
16-
// ^^^
17-
//
18-
// pkg/front_end/testcases/regress/issue_29976.dart:9:5: Error: String starting with " must end with ".
19-
// "x${x*"'"é'}x
20-
// ^^^^^^^^^^^^^^...
21-
//
2222
// pkg/front_end/testcases/regress/issue_29976.dart:12:1: Error: Expected a declaration, but got ''.
2323
//
2424
// pkg/front_end/testcases/regress/issue_29976.dart:9:14: Error: Expected '}' before this.

pkg/front_end/testcases/regress/issue_29976.dart.legacy.transformed.expect

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ library;
22
//
33
// Problems in library:
44
//
5+
// pkg/front_end/testcases/regress/issue_29976.dart:9:15: Error: String starting with ' must end with '.
6+
// "x${x*"'"é'}x
7+
// ^^^
8+
//
59
// pkg/front_end/testcases/regress/issue_29976.dart:9:7: Error: Can't find '}' to match '${'.
610
// "x${x*"'"é'}x
711
// ^
812
//
13+
// pkg/front_end/testcases/regress/issue_29976.dart:9:5: Error: String starting with " must end with ".
14+
// "x${x*"'"é'}x
15+
// ^^^^^^^^^^^^^^...
16+
//
917
// pkg/front_end/testcases/regress/issue_29976.dart:9:14: Error: The non-ASCII character 'é' (U+00E9) can't be used in identifiers, only in strings and comments.
1018
// Try using an US-ASCII letter, a digit, '_' (an underscore), or '$' (a dollar sign).
1119
// "x${x*"'"é'}x
1220
// ^
1321
//
14-
// pkg/front_end/testcases/regress/issue_29976.dart:9:15: Error: String starting with ' must end with '.
15-
// "x${x*"'"é'}x
16-
// ^^^
17-
//
18-
// pkg/front_end/testcases/regress/issue_29976.dart:9:5: Error: String starting with " must end with ".
19-
// "x${x*"'"é'}x
20-
// ^^^^^^^^^^^^^^...
21-
//
2222
// pkg/front_end/testcases/regress/issue_29976.dart:12:1: Error: Expected a declaration, but got ''.
2323
//
2424
// pkg/front_end/testcases/regress/issue_29976.dart:9:14: Error: Expected '}' before this.

0 commit comments

Comments
 (0)