mirror of
https://github.com/dart-lang/sdk
synced 2024-10-02 23:39:19 +00:00
Update AstBuilder to report interpolation in import conditional
Change-Id: If87831a138c14ef913f46b99b044c774d828ea08 Reviewed-on: https://dart-review.googlesource.com/44080 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Dan Rubel <danrubel@google.com>
This commit is contained in:
parent
4f5ad1918c
commit
b3847560e4
|
@ -40,6 +40,7 @@ import 'package:front_end/src/fasta/messages.dart'
|
|||
messageDirectiveAfterDeclaration,
|
||||
messageFieldInitializerOutsideConstructor,
|
||||
messageIllegalAssignmentToNonAssignable,
|
||||
messageInterpolationInUri,
|
||||
messageMissingAssignableSelector,
|
||||
messageNativeClauseShouldBeAnnotation,
|
||||
messageStaticConstructor;
|
||||
|
@ -1584,6 +1585,16 @@ class AstBuilder extends ScopeListener {
|
|||
|
||||
StringLiteral libraryUri = pop();
|
||||
StringLiteral value = popIfNotNull(equalSign);
|
||||
if (value is StringInterpolation) {
|
||||
for (var child in value.childEntities) {
|
||||
if (child is InterpolationExpression) {
|
||||
// This error is reported in OutlineBuilder.endLiteralString
|
||||
handleRecoverableError(
|
||||
messageInterpolationInUri, child.beginToken, child.endToken);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
DottedName name = pop();
|
||||
push(ast.configuration(ifKeyword, leftParen, name, equalSign, value,
|
||||
leftParen?.endGroup, libraryUri));
|
||||
|
|
|
@ -295,6 +295,10 @@ class FastaErrorReporter {
|
|||
length,
|
||||
[type1, type2]);
|
||||
return;
|
||||
case "INVALID_LITERAL_IN_CONFIGURATION":
|
||||
errorReporter?.reportErrorForOffset(
|
||||
ParserErrorCode.INVALID_LITERAL_IN_CONFIGURATION, offset, length);
|
||||
return;
|
||||
case "INVALID_AWAIT_IN_FOR":
|
||||
errorReporter?.reportErrorForOffset(
|
||||
ParserErrorCode.INVALID_AWAIT_IN_FOR, offset, length);
|
||||
|
|
|
@ -510,14 +510,6 @@ class ErrorParserTest_Fasta extends FastaParserTestCase
|
|||
super.test_invalidInterpolationIdentifier_startWithDigit();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
void test_invalidLiteralInConfiguration() {
|
||||
// TODO(brianwilkerson) Wrong errors:
|
||||
// Expected 1 errors of type ParserErrorCode.INVALID_LITERAL_IN_CONFIGURATION, found 0
|
||||
super.test_invalidLiteralInConfiguration();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
void test_invalidOperatorAfterSuper_primaryExpression() {
|
||||
|
|
|
@ -3829,7 +3829,7 @@ class Wrong<T> {
|
|||
Configuration configuration = parser.parseConfiguration();
|
||||
expectNotNullIfNoErrors(configuration);
|
||||
listener.assertErrors([
|
||||
expectedError(ParserErrorCode.INVALID_LITERAL_IN_CONFIGURATION, 9, 9)
|
||||
expectedError(ParserErrorCode.INVALID_LITERAL_IN_CONFIGURATION, 12, 2)
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -2788,6 +2788,8 @@ const Code<Null> codeInterpolationInUri = messageInterpolationInUri;
|
|||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const MessageCode messageInterpolationInUri = const MessageCode(
|
||||
"InterpolationInUri",
|
||||
analyzerCode: "INVALID_LITERAL_IN_CONFIGURATION",
|
||||
dart2jsCode: "*fatal*",
|
||||
message: r"""Can't use string interpolation in a URI.""");
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
|
|
|
@ -1831,6 +1831,8 @@ ExpectedUri:
|
|||
|
||||
InterpolationInUri:
|
||||
template: "Can't use string interpolation in a URI."
|
||||
analyzerCode: INVALID_LITERAL_IN_CONFIGURATION
|
||||
dart2jsCode: "*fatal*"
|
||||
|
||||
IntegerLiteralIsOutOfRange:
|
||||
template: "The integer literal #lexeme can't be represented in 64 bits."
|
||||
|
|
Loading…
Reference in a new issue