blob: 6c3b36e805cc650b56fb648c6e5eb679658622c0 [file] [log] [blame]
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
# Run
#
# dart pkg/front_end/tool/generate_messages.dart
#
# to regenerate messages after having edited this file.
#
# If entries with 'analyzerCode', 'sharedName', or 'index' have been changed,
# run both
#
# dart pkg/front_end/tool/generate_messages.dart
# dart pkg/analyzer/tool/messages/generate.dart
#
# to regenerate analyzer messages.
# Each entry in this map corresponds to a diagnostic message. Ideally, each
# entry contains three parts:
#
# 1. A message template (problemMessage).
#
# 2. A suggestion for how to correct the problem (correctionMessage).
#
# 3. Examples that produce the message (one of expression, statement,
# declaration, member, script, bytes or external). Note that 'external'
# should be the path to an external test. The external test will not be run,
# but the existence of the file will be verified.
#
# Multiple scripts can start with a `// @dart=` annotation to enforce the
# language version used for the example code.
#
# Note that it can be hard or impossible to write an example that only gives the
# specific error. To allow for this, one can specify
# "exampleAllowOtherCodes: true" which filters out every message with a
# different code, and just verifies we got exactly one message of the code in
# question (in addition to different codes).
#
# Note that it can be hard or impossible to write an example that gives the
# specified error exactly once. To allow for this, one can specify
# "exampleAllowMultipleReports: true" which allows for the wanted error to occur
# several times.
#
# If we should also look for the code in the context given on an error pass
# "includeErrorContext: true".
#
# To add examples to experimental features enable the experiment with
# "experiments: <experiment>"
#
# A message shouldn't indicate which kind of diagnostic it is, for example,
# warning or error. Tools are expected to prepend "Warning: ", or "Error: ",
# and should be allowed to change the kind of diagnostic without affecting the
# message. For example, an error might be turned into a warning by the tool.
#
# See the file [lib/src/base/diagnostics.md] for more details on how to write
# good diagnostic messages.
#
# A message used for internal errors should have key that starts with
# "InternalProblem". This way, UX review can prioritize it accordingly.
#
# Eventually, we'd like to have all diagnostics in one shared
# location. However, for now, the analyzer needs to translate error codes to
# its own format. To support this, an entry can contain an analyzer error code
# (analyzerCode).
#
# Long term, the analyzer and front-end need to share the same error codes. So
# eventually all error codes should have an `analyzerCode` field.
# Any error code with an `index` field and an `analyzerCode` field
# will be auto generated as an Analyzer error code.
# `index` field values should be unique, consecutive whole numbers starting with 1.
# If `index` is defined, then `analyzerCode` should be the fully formed
# name of the corresponding public Analyzer error const
# (e.g. ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND)
# which will be used when generating code in Analyzer for translating
# cfe error codes to Analyzer error codes.
# If `index` is ever removed, then a new entry needs to be added at
# `pkg\analyzer\messages.yaml` for that code and the biggest index can be replaced
# by the removed one.
# If `sharedName` is defined, the generated analyzer code will use this as the
# user-facing analyzer code instead of `analyzerCode`. Multiple messages can share
# the `sharedName`.
#
# Errors with an `index` can also optionally contain user-facing documentation
# for the problem (documentation), which dart.dev will extract,
# as well as internal documentation (comment), which will be included in
# the code generated for the analyzer.
#
# In some cases a message is internal to the frontend, and no meaningful
# analyzer code can be provided. In such cases set `frontendInternal: true`.
#
# ## Parameter Substitution in problemMessage and correctionMessage
#
# The fields `problemMessage` and `correctionMessage` are subject to parameter
# substitution. When the compiler reports a problem, it must also specify
# parameters to be substituted into the message.
#
# Parameters are declared using a map called `parameters`; each map key is of
# the form `TYPE NAME`, and each map value is a comment describing the
# parameter. Placeholders in the `problemMessage` and `correctionMessage`
# strings take the form `#NAME`.
#
# If a diagnostic takes no parameters, it must have an entry of the
# form `parameters: none`.
#
# The following TYPEs are supported:
#
# - `Character`: a Unicode character.
#
# - `Constant`: a Kernel constant.
#
# - `int`: an integer (typically a count).
#
# - `Name` a name string. Note that asserts check to make sure the
# parameter is not empty. If the diagnostic needs to support an
# empty name, use `NameOKEmpty` instead.
#
# - `NameOKEmpty`: a name string. Will use an "(unnamed)" default message if
# the string is empty.
#
# - `Names`: A list of names (strings).
#
# - `Num`: a number (int or double). Formatting can be controlled
# using a `%` in the placeholder: `#NAME%N.M` formats the number to
# minimum width N with M fraction digits.
#
# - `String`: a string that isn't a name. Note: as a rule of thumb,
# avoid using this type. In particular, do not it for composing
# error messages, see [diagnostics.md](
# lib/src/base/diagnostics.md#avoid-composing-messages-programmatically).
# Note that asserts check to make sure the parameter is not
# empty. If the diagnostic needs to support an empty name, use
# `StringOKEmpty` instead.
#
# - `StringOKEmpty`: a string (that isn't a name). Will use an
# "(empty)" default message if the string is empty.
#
# - `Token`: a token. The token's `lexeme` property is used.
#
# - `Type`: a kernel type.
#
# - `Unicode`: a Unicode short identifier (U+xxxx). We use this to
# represent code units or code points.
#
# - `Uri`: a URI.
AsciiControlCharacter:
parameters:
Unicode character: the unexpected control character.
problemMessage: "The control character #character can only be used in strings and comments."
analyzerCode: ILLEGAL_CHARACTER
expression: "\x1b 1"
ConstEvalStartingPoint:
parameters: none
problemMessage: "Constant evaluation error:"
ConstEvalContext:
parameters: none
problemMessage: "While analyzing:"
severity: CONTEXT
ConstEvalDuplicateElement:
parameters:
Constant constant: undocumented
problemMessage: "The element '#constant' conflicts with another existing element in the set."
analyzerCode: EQUAL_ELEMENTS_IN_CONST_SET
script: |
const foo = {1, 1};
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalDuplicateKey:
parameters:
Constant constant: undocumented
problemMessage: "The key '#constant' conflicts with another existing key in the map."
analyzerCode: EQUAL_KEYS_IN_CONST_MAP
script: |
const foo = {1: 2, 1: 3};
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalElementImplementsEqual:
parameters:
Constant constant: undocumented
problemMessage: "The element '#constant' does not have a primitive operator '=='."
analyzerCode: CONST_SET_ELEMENT_TYPE_IMPLEMENTS_EQUALS
script: |
//@dart=2.18
const Set<dynamic> setWithNonPrimitiveEquals = {const WithEquals(42)};
class WithEquals {
final int i;
const WithEquals(this.i);
operator ==(Object o) {
return o is WithEquals && (o as WithEquals).i == i;
}
}
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalElementNotPrimitiveEquality:
parameters:
Constant constant: undocumented
problemMessage: "The element '#constant' does not have a primitive equality."
script: |
const Set<dynamic> setWithNonPrimitiveEquals = {const WithEquals(42)};
class WithEquals {
final int i;
const WithEquals(this.i);
operator ==(Object o) {
return o is WithEquals && (o as WithEquals).i == i;
}
}
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalKeyImplementsEqual:
parameters:
Constant constant: undocumented
problemMessage: "The key '#constant' does not have a primitive operator '=='."
analyzerCode: CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
ConstEvalKeyNotPrimitiveEquality:
parameters:
Constant constant: undocumented
problemMessage: "The key '#constant' does not have a primitive equality."
script: |
const Map<dynamic, int> mapWithNonPrimitiveEqualsKey = {
const WithEquals(42): 42
};
class WithEquals {
final int i;
const WithEquals(this.i);
operator ==(Object o) {
return o is WithEquals && (o as WithEquals).i == i;
}
}
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalCaseImplementsEqual:
parameters:
Constant constant: undocumented
problemMessage: "Case expression '#constant' does not have a primitive operator '=='."
script: |
// @dart=2.19
bar(dynamic x) {
switch (x) {
case const D(): break;
default:
}
}
class D {
const D();
bool operator ==(dynamic other) => identical(this, other);
}
ConstEvalInvalidType:
parameters:
Constant constant: undocumented
Type type: undocumented
Type type2: undocumented
problemMessage: "Expected constant '#constant' to be of type '#type', but was of type '#type2'."
script: |
const Map foo = {...bar};
const dynamic bar = "Hello";
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalInvalidBinaryOperandType:
parameters:
StringOKEmpty stringOKEmpty: undocumented
Constant constant: undocumented
Type type: undocumented
Type type2: undocumented
problemMessage: "Binary operator '#stringOKEmpty' on '#constant' requires operand of type '#type', but was of type '#type2'."
script: |
const dynamic willBeDouble = const bool.fromEnvironment("foo") ? 42 : 42.42;
const binaryOnDouble = willBeDouble << 2;
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalInvalidEqualsOperandType:
parameters:
Constant constant: undocumented
Type type: undocumented
problemMessage: "Binary operator '==' requires receiver constant '#constant' of type 'Null', 'bool', 'int', 'double', or 'String', but was of type '#type'."
script: |
//@dart=2.18
class Foo {
const Foo();
}
const f = Foo();
const b = f == f;
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalEqualsOperandNotPrimitiveEquality:
parameters:
Constant constant: undocumented
Type type: undocumented
problemMessage: "Binary operator '==' requires receiver constant '#constant' of a type with primitive equality or type 'double', but was of type '#type'."
script: |
const FooWithHashCodeField fooWithHashCodeField1 = const FooWithHashCodeField(42);
const FooWithHashCodeField fooWithHashCodeField2 = const FooWithHashCodeField(42);
const bool fooWithHashCodeFieldEqual = fooWithHashCodeField1 == fooWithHashCodeField2;
class FooWithHashCodeField {
final int x;
final int hashCode;
const FooWithHashCodeField(int x) : this.x = x, this.hashCode = x * 42;
}
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalZeroDivisor:
parameters:
String string: undocumented
String string2: undocumented
problemMessage: "Binary operator '#string' on '#string2' requires non-zero divisor, but divisor was '0'."
analyzerCode: CONST_EVAL_THROWS_IDBZE
script: |
const int i = 42 ~/ 0;
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalNegativeShift:
parameters:
String string: undocumented
String string2: undocumented
String string3: undocumented
problemMessage: "Binary operator '#string' on '#string2' requires non-negative operand, but was '#string3'."
script: |
const int foo = 42 >> -1;
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalTruncateError:
parameters:
String string: undocumented
String string2: undocumented
problemMessage: "Binary operator '#string ~/ #string2' results is Infinity or NaN."
script: |
const double doubleNan = 0/0;
const int doubleTruncateDivNaN = 84.2 ~/ doubleNan;
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalNonNull:
parameters: none
problemMessage: "Constant expression must be non-null."
experiments: const-functions
script: |
const int x = y!;
const dynamic y = null;
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalGetterNotFound:
parameters:
NameOKEmpty nameOKEmpty: undocumented
problemMessage: "Variable get not found: '#nameOKEmpty'"
ConstEvalInvalidMethodInvocation:
parameters:
StringOKEmpty stringOKEmpty: undocumented
Constant constant: undocumented
problemMessage: "The method '#stringOKEmpty' can't be invoked on '#constant' in a constant expression."
analyzerCode: UNDEFINED_OPERATOR
script: |
const List<String> listConcat = ["Hello"] + ["World"];
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalInvalidPropertyGet:
parameters:
StringOKEmpty stringOKEmpty: undocumented
Constant constant: undocumented
problemMessage: "The property '#stringOKEmpty' can't be accessed on '#constant' in a constant expression."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalInvalidRecordIndexGet:
parameters:
StringOKEmpty stringOKEmpty: undocumented
Constant constant: undocumented
problemMessage: "The property '#stringOKEmpty' can't be accessed on '#constant' in a constant expression."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalInvalidRecordNameGet:
parameters:
StringOKEmpty stringOKEmpty: undocumented
Constant constant: undocumented
problemMessage: "The property '#stringOKEmpty' can't be accessed on '#constant' in a constant expression."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalInvalidStringInterpolationOperand:
parameters:
Constant constant: undocumented
problemMessage: |
The constant value '#constant' can't be used as part of a string interpolation in a constant expression.
Only values of type 'null', 'bool', 'int', 'double', or 'String' can be used.
analyzerCode: CONST_EVAL_TYPE_BOOL_NUM_STRING
script: |
class Foo {
const Foo();
}
const f = Foo();
const bar = "hello $f";
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalInvalidStaticInvocation:
parameters:
NameOKEmpty nameOKEmpty: undocumented
problemMessage: "The invocation of '#nameOKEmpty' is not allowed in a constant expression."
analyzerCode: CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
ConstEvalInvalidSymbolName:
parameters:
Constant constant: undocumented
problemMessage: "The symbol name must be a valid public Dart member name, public constructor name, or library name, optionally qualified, but was '#constant'."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalFailedAssertion:
parameters: none
problemMessage: "This assertion failed."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
script: |
class Foo {
final int x;
const Foo(this.x) : assert(x < 0);
}
const Foo foo = const Foo(42);
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalFailedAssertionWithMessage:
parameters:
StringOKEmpty stringOKEmpty: undocumented
problemMessage: "This assertion failed with message: #stringOKEmpty"
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
script: |
class Foo {
final int x;
const Foo(this.x) : assert(x < 0, "non-negative");
}
const Foo foo = const Foo(42);
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalFailedAssertionWithNonStringMessage:
parameters: none
problemMessage: "This assertion failed with a non-String message."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
script: |
class Foo {
final int x;
const Foo(this.x) : assert(x < 0, x);
}
const Foo foo = const Foo(42);
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalNonConstantVariableGet:
parameters:
NameOKEmpty nameOKEmpty: undocumented
problemMessage: "The variable '#nameOKEmpty' is not a constant, only constant expressions are allowed."
analyzerCode: NON_CONSTANT_VALUE_IN_INITIALIZER
ConstEvalDeferredLibrary:
parameters:
NameOKEmpty nameOKEmpty: undocumented
problemMessage: >
'#nameOKEmpty' can't be used in a constant expression because it's marked as
'deferred' which means it isn't available until loaded.
correctionMessage: >
Try moving the constant from the deferred library, or removing 'deferred'
from the import.
analyzerCode: INVALID_ANNOTATION_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY
script:
main.dart: |
import "lib.dart" deferred as foo;
void bar() => const [foo.c];
lib.dart: |
const c = const C();
class C {
const C();
}
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalCircularity:
parameters: none
problemMessage: "Constant expression depends on itself."
analyzerCode: RECURSIVE_COMPILE_TIME_CONSTANT
script: |
const foo = bar;
const bar = foo;
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalNullValue:
parameters: none
problemMessage: "Null value during constant evaluation."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
experiments: const-functions
script: |
const dynamic a = null;
const dynamic b = a();
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalNotListOrSetInSpread:
parameters: none
problemMessage: "Only lists and sets can be used in spreads in constant lists and sets."
analyzerCode: CONST_SPREAD_EXPECTED_LIST_OR_SET
script: |
import 'dart:collection';
class CustomIterable extends IterableBase<String> {
const CustomIterable();
Iterator<String> get iterator => <String>[].iterator;
}
const List<String> barWithCustomIterableSpread1 = [
...const CustomIterable()
];
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalNotMapInSpread:
parameters: none
problemMessage: "Only maps can be used in spreads in constant maps."
analyzerCode: CONST_SPREAD_EXPECTED_MAP
script: |
const Map<String, String> mapWithCustomMap1 = {...const CustomMap()};
class CustomMap implements Map<String, String> {
const CustomMap();
@override
Iterable<MapEntry<String, String>> get entries => [];
@override
String operator [](Object? key) => throw new UnimplementedError();
@override
void operator []=(String key, String value) => throw new UnimplementedError();
@override
Map<RK, RV> cast<RK, RV>() => throw new UnimplementedError();
@override
void clear() => throw new UnimplementedError();
@override
bool containsKey(Object? key) => throw new UnimplementedError();
@override
bool containsValue(Object? value) => throw new UnimplementedError();
@override
bool get isEmpty => throw new UnimplementedError();
@override
bool get isNotEmpty => throw new UnimplementedError();
@override
Iterable<String> get keys => throw new UnimplementedError();
@override
int get length => throw new UnimplementedError();
@override
String remove(Object? key) => throw new UnimplementedError();
@override
Iterable<String> get values => throw new UnimplementedError();
@override
void addAll(Map<String, String> other) => throw new UnimplementedError();
@override
void addEntries(Iterable<MapEntry<String, String>> newEntries) =>
throw new UnimplementedError();
@override
void forEach(void f(String key, String value)) =>
throw new UnimplementedError();
@override
String putIfAbsent(String key, String ifAbsent()) =>
throw new UnimplementedError();
@override
void updateAll(String update(String key, String value)) =>
throw new UnimplementedError();
@override
void removeWhere(bool predicate(String key, String value)) =>
throw new UnimplementedError();
String update(String key, String update(String value),
{String ifAbsent()?}) =>
throw new UnimplementedError();
Map<K2, V2> map<K2, V2>(MapEntry<K2, V2> f(String key, String value)) =>
throw new UnimplementedError();
}
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalExtension:
parameters: none
problemMessage: "Extension operations can't be used in constant expressions."
analyzerCode: NOT_CONSTANT_EXPRESSION
experiments: const-functions
script: |
extension Foo on int {
int x() => 42;
}
const bar = 1.x();
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalExternalConstructor:
parameters: none
problemMessage: "External constructors can't be evaluated in constant expressions."
script: |
class Foo {
external const Foo();
}
const bar = Foo();
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalExternalFactory:
parameters: none
problemMessage: "External factory constructors can't be evaluated in constant expressions."
script: |
class Foo {
external const factory Foo();
}
const bar = Foo();
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalUnevaluated:
parameters: none
problemMessage: "Couldn't evaluate constant expression."
ConstEvalError:
parameters:
String string: undocumented
problemMessage: "Error evaluating constant expression: #string"
ConstEvalUnhandledCoreException:
parameters:
StringOKEmpty stringOKEmpty: undocumented
problemMessage: "Unhandled core exception: #stringOKEmpty"
experiments: const-functions
script: |
const foo = [].single;
includeErrorContext: true
exampleAllowOtherCodes: true
ConstEvalUnhandledException:
parameters:
Constant constant: undocumented
problemMessage: "Unhandled exception: #constant"
experiments: const-functions
script: |
const foo = doThrow();
int doThrow() => throw 42;
includeErrorContext: true
exampleAllowOtherCodes: true
NotConstantExpression:
parameters:
String string: undocumented
problemMessage: "#string is not a constant expression."
analyzerCode: NOT_CONSTANT_EXPRESSION
script: |
void foo() {
const x = new Map();
}
exampleAllowMultipleReports: true
NotAConstantExpression:
parameters: none
problemMessage: "Not a constant expression."
analyzerCode: NOT_CONSTANT_EXPRESSION
script: |
foo() {
var a = 0;
const b = a;
}
MissingExplicitConst:
parameters: none
problemMessage: "Constant expression expected."
correctionMessage: "Try inserting 'const'."
analyzerCode: NOT_CONSTANT_EXPRESSION
script: |
class A {
final x;
const A(): x = [];
}
DynamicCallsAreNotAllowedInDynamicModule:
parameters: none
problemMessage: "Dynamic calls are not allowed in a dynamic module."
ConstructorShouldBeListedAsCallableInDynamicInterface:
parameters:
Name name: undocumented
problemMessage: "Cannot invoke constructor '#name' from a dynamic module."
correctionMessage: "Try removing the call or update the dynamic interface to list constructor '#name' as callable."
MemberShouldBeListedAsCallableInDynamicInterface:
parameters:
Name name: undocumented
problemMessage: "Cannot invoke member '#name' from a dynamic module."
correctionMessage: "Try removing the call or update the dynamic interface to list member '#name' as callable."
ExtensionTypeShouldBeListedAsCallableInDynamicInterface:
parameters:
Name name: undocumented
problemMessage: "Cannot use extension type '#name' in a dynamic module."
correctionMessage: "Try removing the reference to extension type '#name' or update the dynamic interface to list extension type '#name' as callable."
ClassShouldBeListedAsCallableInDynamicInterface:
parameters:
Name name: undocumented
problemMessage: "Cannot use class '#name' in a dynamic module."
correctionMessage: "Try removing the reference to class '#name' or update the dynamic interface to list class '#name' as callable."
ClassShouldBeListedAsExtendableInDynamicInterface:
parameters:
Name name: undocumented
problemMessage: "Cannot extend, implement or mix-in class '#name' in a dynamic module."
correctionMessage: "Try removing the reference to class '#name' or update the dynamic interface to list class '#name' as extendable."
MemberShouldBeListedAsCanBeOverriddenInDynamicInterface:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "Cannot override member '#name.#name2' in a dynamic module."
correctionMessage: "Try removing the override or update the dynamic interface to list member '#name.#name2' as can-be-overridden."
NonAsciiIdentifier:
parameters:
Character character: undocumented
Unicode unicode: undocumented
problemMessage: "The non-ASCII character '#character' (#unicode) can't be used in identifiers, only in strings and comments."
correctionMessage: "Try using an US-ASCII letter, a digit, '_' (an underscore), or '$' (a dollar sign)."
analyzerCode: ILLEGAL_CHARACTER
expression: "Ã¥"
exampleAllowOtherCodes: true
NonAsciiWhitespace:
parameters:
Unicode unicode: undocumented
problemMessage: "The non-ASCII space character #unicode can only be used in strings and comments."
analyzerCode: ILLEGAL_CHARACTER
expression: "\u2028 1"
Encoding:
parameters: none
problemMessage: "Unable to decode bytes as UTF-8."
bytes: [255]
ExperimentNotEnabled:
parameters:
String string: undocumented
String string2: undocumented
index: 48
problemMessage: "This requires the '#string' language feature to be enabled."
correctionMessage: "Try updating your pubspec.yaml to set the minimum SDK constraint to #string2 or higher, and running 'pub get'."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED
ExperimentNotEnabledOffByDefault:
parameters:
String string: undocumented
index: 133
problemMessage: "This requires the experimental '#string' language feature to be enabled."
correctionMessage: "Try passing the '--enable-experiment=#string' command line option."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED_OFF_BY_DEFAULT
script: |
// @dart=3.5
void foo() {
int i = 42_42_42_42;
}
ExperimentDisabled:
parameters:
String string: undocumented
problemMessage: "This requires the '#string' language feature to be enabled."
correctionMessage: "The feature is on by default but is currently disabled, maybe because the '--enable-experiment=no-#string' command line option is passed."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED
ExperimentDisabledInvalidLanguageVersion:
parameters:
String string: undocumented
String string2: undocumented
problemMessage: "This requires the '#string' language feature, which requires language version of #string2 or higher."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED
EmptyNamedParameterList:
parameters: none
problemMessage: "Named parameter lists cannot be empty."
correctionMessage: "Try adding a named parameter to the list."
analyzerCode: "MISSING_IDENTIFIER"
script: |
foo({}) {}
main() {
foo();
}
RecordLiteralOnePositionalFieldNoTrailingComma:
parameters: none
problemMessage: "A record literal with exactly one positional field requires a trailing comma."
correctionMessage: "Try adding a trailing comma."
analyzerCode: ParserErrorCode.RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA
index: 127
hasPublishedDocs: true
documentation: |-
#### Description
The analyzer produces this diagnostic when a record literal with a single
positional field doesn't have a trailing comma after the field.
In some locations a record literal with a single positional field could
also be a parenthesized expression. A trailing comma is required to
disambiguate these two valid interpretations.
#### Example
The following code produces this diagnostic because the record literal has
one positional field but doesn't have a trailing comma:
```dart
var r = const (1[!)!];
```
#### Common fixes
Add a trailing comma:
```dart
var r = const (1,);
```
script: |
main() {
var record = const (1);
}
RecordLiteralZeroFieldsWithTrailingComma:
parameters: none
problemMessage: "A record literal without fields can't have a trailing comma."
correctionMessage: "Try removing the trailing comma."
analyzerCode: ParserErrorCode.EMPTY_RECORD_LITERAL_WITH_COMMA
index: 128
hasPublishedDocs: true
documentation: |-
#### Description
The analyzer produces this diagnostic when a record literal that has no
fields has a trailing comma. Empty record literals can't contain a comma.
#### Example
The following code produces this diagnostic because the empty record
literal has a trailing comma:
```dart
var r = ([!,!]);
```
#### Common fixes
If the record is intended to be empty, then remove the comma:
```dart
var r = ();
```
If the record is intended to have one or more fields, then add the
expressions used to compute the values of those fields:
```dart
var r = (3, 4);
```
script: |
main() {
var record = (,);
}
EmptyRecordTypeNamedFieldsList:
parameters: none
problemMessage: "The list of named fields in a record type can't be empty."
correctionMessage: "Try adding a named field to the list."
analyzerCode: ParserErrorCode.EMPTY_RECORD_TYPE_NAMED_FIELDS_LIST
index: 129
hasPublishedDocs: true
documentation: |-
#### Description
The analyzer produces this diagnostic when a record type has an empty list
of named fields.
#### Example
The following code produces this diagnostic because the record type has an
empty list of named fields:
```dart
void f((int, int, {[!}!]) r) {}
```
#### Common fixes
If the record is intended to have named fields, then add the types and
names of the fields:
```dart
void f((int, int, {int z}) r) {}
```
If the record isn't intended to have named fields, then remove the curly
braces:
```dart
void f((int, int) r) {}
```
script: |
main() {
(int, int, {/*missing*/}) record = (1, 2,);
}
RecordTypeZeroFieldsButTrailingComma:
parameters: none
problemMessage: "A record type without fields can't have a trailing comma."
correctionMessage: "Try removing the trailing comma."
analyzerCode: ParserErrorCode.EMPTY_RECORD_TYPE_WITH_COMMA
index: 130
hasPublishedDocs: true
documentation: |-
#### Description
The analyzer produces this diagnostic when a record type that has no
fields has a trailing comma. Empty record types can't contain a comma.
#### Example
The following code produces this diagnostic because the empty record type
has a trailing comma:
```dart
void f(([!,!]) r) {}
```
#### Common fixes
If the record type is intended to be empty, then remove the comma:
```dart
void f(() r) {}
```
If the record type is intended to have one or more fields, then add the
types of those fields:
```dart
void f((int, int) r) {}
```
script: |
main() {
(,) record = ();
}
RecordTypeOnePositionalFieldNoTrailingComma:
parameters: none
problemMessage: "A record type with exactly one positional field requires a trailing comma."
correctionMessage: "Try adding a trailing comma."
analyzerCode: ParserErrorCode.RECORD_TYPE_ONE_POSITIONAL_NO_TRAILING_COMMA
index: 131
hasPublishedDocs: true
documentation: |-
#### Description
The analyzer produces this diagnostic when a record type annotation with a
single positional field doesn't have a trailing comma after the field.
In some locations a record type with a single positional field could also
be a parenthesized expression. A trailing comma is required to
disambiguate these two valid interpretations.
#### Example
The following code produces this diagnostic because the record type has
one positional field, but doesn't have a trailing comma:
```dart
void f((int[!)!] r) {}
```
#### Common fixes
Add a trailing comma:
```dart
void f((int,) r) {}
```
script: |
main() {
(int /* missing trailing comma */) record = const (1, );
}
DuplicatedRecordTypeFieldName:
parameters:
Name name: undocumented
problemMessage: "Duplicated record type field name '#name'."
correctionMessage: "Try renaming or removing one of the named record type fields."
script: |
({int a, String a}) record = throw '';
DuplicatedRecordTypeFieldNameContext:
parameters:
Name name: undocumented
problemMessage: "This is the existing record type field named '#name'."
severity: CONTEXT
DuplicatedRecordLiteralFieldName:
parameters:
Name name: undocumented
problemMessage: "Duplicated record literal field name '#name'."
correctionMessage: "Try renaming or removing one of the named record literal fields."
script: |
dynamic field = (a: 0, a: 1);
DuplicatedRecordLiteralFieldNameContext:
parameters:
Name name: undocumented
problemMessage: "This is the existing record literal field named '#name'."
severity: CONTEXT
EmptyOptionalParameterList:
parameters: none
problemMessage: "Optional parameter lists cannot be empty."
correctionMessage: "Try adding an optional parameter to the list."
analyzerCode: "MISSING_IDENTIFIER"
script: |
foo([]) {}
main() {
foo();
}
ExpectedElseOrComma:
parameters: none
index: 46
problemMessage: "Expected 'else' or comma."
analyzerCode: ParserErrorCode.EXPECTED_ELSE_OR_COMMA
script: |
void foo(int i) {
var x = [
if (i > 2) 2
2
];
}
ExpectedBlockToSkip:
parameters: none
problemMessage: "Expected a function body or '=>'."
# TODO(ahe): In some scenarios, we can suggest removing the 'static' keyword.
correctionMessage: "Try adding {}."
analyzerCode: MISSING_FUNCTION_BODY
ExpectedBody:
parameters: none
problemMessage: "Expected a function body or '=>'."
# TODO(ahe): In some scenarios, we can suggest removing the 'static' keyword.
correctionMessage: "Try adding {}."
analyzerCode: MISSING_FUNCTION_BODY
script: "main();"
ExpectedStatement:
parameters: none
index: 29
problemMessage: "Expected a statement."
analyzerCode: ParserErrorCode.MISSING_STATEMENT
statement: "void;"
ExpectedButGot:
# Also see ExpectedAfterButGot and ExpectedInstead
parameters:
String string: undocumented
problemMessage: "Expected '#string' before this."
# Consider the second example below: the parser expects a ')' before 'y', but
# a ',' would also have worked. We don't have enough information to give a
# good suggestion.
analyzerCode: EXPECTED_TOKEN
exampleAllowOtherCodes: true
script:
- "main() => true ? 1;"
- "main() => foo(x: 1 y: 2);"
ExpectedAfterButGot:
# Also see ExpectedButGot and ExpectedInstead
parameters:
String string: undocumented
problemMessage: "Expected '#string' after this."
# This is an alternative to ExpectedButGot when it's better for the error to be
# associated with the last consumed token rather than the token being parsed.
# Doing so can make it cognitively easier for the user to understand and fix.
#
# For example, this is ok...
#
# x = 7
# class Foo {
# ^^^^^
# Expected ';' before this
#
# but this is easier for the user...
#
# x = 7
# ^
# Expected ';' after this
# class Foo {
#
analyzerCode: EXPECTED_TOKEN
script:
- "main() { return true }"
ExpectedInstead:
# Also see ExpectedButGot and ExpectedAfterButGot
parameters:
String string: undocumented
index: 41
problemMessage: "Expected '#string' instead of this."
# This is an alternative to ExpectedButGot when the last consumed token
# should be replaced with a different token.
#
# For example, this is ok...
#
# mixin Foo extends Bar {
# ^^^^^^^
# Expected 'on' before this
#
# but this is easier for the user...
#
# mixin Foo extends Bar {
# ^^^^^^^
# Expected 'on' instead of this
#
analyzerCode: ParserErrorCode.EXPECTED_INSTEAD
script:
- "class B {} mixin A extends B { }"
MultipleLibraryDirectives:
parameters: none
index: 27
problemMessage: "Only one library directive may be declared in a file."
correctionMessage: "Try removing all but one of the library directives."
analyzerCode: ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES
script:
library foo;
library bar;
MultipleExtends:
parameters: none
index: 28
problemMessage: "Each class definition can have at most one extends clause."
correctionMessage: "Try choosing one superclass and define your class to implement (or mix in) the others."
analyzerCode: ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES
script:
- "class B{} class C{} class A extends B extends C {}"
- "class B{} class C{} class A extends B, C {}"
MultipleWith:
parameters: none
index: 24
problemMessage: "Each class definition can have at most one with clause."
correctionMessage: "Try combining all of the with clauses into a single clause."
analyzerCode: ParserErrorCode.MULTIPLE_WITH_CLAUSES
script: "class A extends B with C, D with E {}"
exampleAllowOtherCodes: true
WithBeforeExtends:
parameters: none
index: 11
problemMessage: "The extends clause must be before the with clause."
correctionMessage: "Try moving the extends clause before the with clause."
analyzerCode: ParserErrorCode.WITH_BEFORE_EXTENDS
script: "mixin B {} class C {} class A with B extends C {}"
ImplementsBeforeExtends:
parameters: none
index: 44
problemMessage: "The extends clause must be before the implements clause."
correctionMessage: "Try moving the extends clause before the implements clause."
analyzerCode: ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS
script: "class A implements B extends C {}"
exampleAllowOtherCodes: true
ImplementsBeforeOn:
parameters: none
index: 43
problemMessage: "The on clause must be before the implements clause."
correctionMessage: "Try moving the on clause before the implements clause."
analyzerCode: ParserErrorCode.IMPLEMENTS_BEFORE_ON
script: "mixin A implements B on C {}"
exampleAllowOtherCodes: true
ImplementsBeforeWith:
parameters: none
index: 42
problemMessage: "The with clause must be before the implements clause."
correctionMessage: "Try moving the with clause before the implements clause."
analyzerCode: ParserErrorCode.IMPLEMENTS_BEFORE_WITH
script: "class A extends B implements C with D {}"
exampleAllowOtherCodes: true
ImplementsRepeated:
parameters:
Name name: undocumented
int count: undocumented
problemMessage: "'#name' can only be implemented once."
analyzerCode: IMPLEMENTS_REPEATED
correctionMessage: "Try removing #count of the occurrences."
script:
- >-
abstract class I {}
abstract class J {}
class K implements I, J, I {}
ImplementsSuperClass:
parameters:
Name name: undocumented
problemMessage: "'#name' can't be used in both 'extends' and 'implements' clauses."
analyzerCode: IMPLEMENTS_SUPER_CLASS
correctionMessage: "Try removing one of the occurrences."
script:
- >-
abstract class A {}
class C extends A implements A {}
MultipleImplements:
parameters: none
problemMessage: "Each class definition can have at most one implements clause."
correctionMessage: "Try combining all of the implements clauses into a single clause."
analyzerCode: MULTIPLE_IMPLEMENTS_CLAUSES
script: "class A implements B implements C, D {}"
exampleAllowOtherCodes: true
MultipleClauses:
parameters:
String string: undocumented
String string2: undocumented
problemMessage: "Each '#string' definition can have at most one '#string2' clause."
correctionMessage: "Try combining all of the '#string2' clauses into a single clause."
analyzerCode: ParserErrorCode.MULTIPLE_CLAUSES
index: 121
script:
- "mixin B {} enum A implements B implements C, D { v; }"
- "mixin B {} enum A with B with C, D { v; }"
OutOfOrderClauses:
parameters:
String string: undocumented
String string2: undocumented
problemMessage: "The '#string' clause must come before the '#string2' clause."
correctionMessage: "Try moving the '#string' clause before the '#string2' clause."
analyzerCode: ParserErrorCode.OUT_OF_ORDER_CLAUSES
index: 122
script: "class B {} class D {} enum A implements B with D { v; }"
MultipleOnClauses:
parameters: none
index: 26
problemMessage: "Each mixin definition can have at most one on clause."
correctionMessage: "Try combining all of the on clauses into a single clause."
analyzerCode: ParserErrorCode.MULTIPLE_ON_CLAUSES
script: "mixin A on B on C, D {}"
exampleAllowOtherCodes: true
MixinWithClause:
parameters: none
index: 154
problemMessage: "A mixin can't have a with clause."
analyzerCode: ParserErrorCode.MIXIN_WITH_CLAUSE
script: "mixin M {} mixin N with M {}"
ImplementsFutureOr:
parameters: none
problemMessage: "The type 'FutureOr' can't be used in an 'implements' clause."
script: |
import 'dart:async';
class Foo implements FutureOr<String> {}
ExtendsNever:
parameters: none
problemMessage: "The type 'Never' can't be used in an 'extends' clause."
script: |
class Foo extends Never {}
exampleAllowOtherCodes: true
ImplementsNever:
parameters: none
problemMessage: "The type 'Never' can't be used in an 'implements' clause."
script:
class Foo implements Never {}
exampleAllowOtherCodes: true
ExpectedClassBody:
parameters: none
index: 8
problemMessage: "A class declaration must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_CLASS_BODY
sharedName: EXPECTED_BODY
script: |
class Class
ExpectedMixinBody:
parameters: none
index: 166
problemMessage: "A mixin declaration must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_MIXIN_BODY
sharedName: EXPECTED_BODY
script: |
mixin Mixin
ExpectedExtensionBody:
parameters: none
index: 173
problemMessage: "An extension declaration must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_EXTENSION_BODY
sharedName: EXPECTED_BODY
script: |
extension Extension on int
ExpectedExtensionTypeBody:
parameters: none
index: 167
problemMessage: "An extension type declaration must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_EXTENSION_TYPE_BODY
sharedName: EXPECTED_BODY
script: |
extension type ExtensionType(int i)
ExpectedTryStatementBody:
parameters: none
index: 168
problemMessage: "A try statement must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_TRY_STATEMENT_BODY
sharedName: EXPECTED_BODY
script: |
method() {
try finally {}
}
ExpectedCatchClauseBody:
parameters: none
index: 169
problemMessage: "A catch clause must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_CATCH_CLAUSE_BODY
sharedName: EXPECTED_BODY
script: |
method() {
try {} catch (_);
}
ExpectedFinallyClauseBody:
parameters: none
index: 170
problemMessage: "A finally clause must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_FINALLY_CLAUSE_BODY
sharedName: EXPECTED_BODY
script: |
method() {
try {} finally;
}
ExpectedSwitchExpressionBody:
parameters: none
index: 171
problemMessage: "A switch expression must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_SWITCH_EXPRESSION_BODY
sharedName: EXPECTED_BODY
script: |
method(Never n) => switch (n);
ExpectedSwitchStatementBody:
parameters: none
index: 172
problemMessage: "A switch statement must have a body, even if it is empty."
correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_SWITCH_STATEMENT_BODY
sharedName: EXPECTED_BODY
script: |
method(Never n) {
switch (n);
}
ExpectedDeclaration:
parameters:
Token lexeme: undocumented
problemMessage: "Expected a declaration, but got '#lexeme'."
analyzerCode: EXPECTED_EXECUTABLE
script: |
var get b, c;
exampleAllowOtherCodes: true
ExpectedClassMember:
parameters:
Token lexeme: undocumented
problemMessage: "Expected a class member, but got '#lexeme'."
analyzerCode: EXPECTED_CLASS_MEMBER
script: |
class Foo {
Foo() : this.new = 42;
}
exampleAllowOtherCodes: true
exampleAllowMultipleReports: true
ExpectedFunctionBody:
parameters:
Token lexeme: undocumented
problemMessage: "Expected a function body, but got '#lexeme'."
analyzerCode: MISSING_FUNCTION_BODY
script: |
var get b, c;
exampleAllowOtherCodes: true
exampleAllowMultipleReports: true
ExpectedHexDigit:
parameters: none
problemMessage: "A hex digit (0-9 or A-F) must follow '0x'."
# No tip, seems obvious from the error message.
analyzerCode: MISSING_HEX_DIGIT
script: |
main() {
var i = 0x;
}
ExpectedIdentifier:
parameters:
Token lexeme: undocumented
problemMessage: "Expected an identifier, but got '#lexeme'."
correctionMessage: "Try inserting an identifier before '#lexeme'."
analyzerCode: MISSING_IDENTIFIER
script: "var = 42;"
ExpectedIdentifierButGotKeyword:
parameters:
Token lexeme: undocumented
problemMessage: "'#lexeme' can't be used as an identifier because it's a keyword."
correctionMessage: "Try renaming this to be an identifier that isn't a keyword."
index: 113
analyzerCode: ParserErrorCode.EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD
script: "var default = 42;"
EqualityCannotBeEqualityOperand:
parameters: none
index: 1
problemMessage: "A comparison expression can't be an operand of another comparison expression."
correctionMessage: "Try putting parentheses around one of the comparisons."
analyzerCode: ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND
exampleAllowOtherCodes: true
script:
- "main() { var b = a < b < c; }"
- "main() { var b = a == b != c; }"
ExpectedString:
parameters:
Token lexeme: undocumented
problemMessage: "Expected a String, but got '#lexeme'."
analyzerCode: EXPECTED_STRING_LITERAL
script: |
import foo;
exampleAllowOtherCodes: true
ExpectedToken:
parameters:
String string: undocumented
problemMessage: "Expected to find '#string'."
analyzerCode: EXPECTED_TOKEN
script: |
void foo() {
switch (1) {
C<int, int> case 1: break;
}
}
ExpectedType:
parameters:
Token lexeme: undocumented
problemMessage: "Expected a type, but got '#lexeme'."
analyzerCode: EXPECTED_TYPE_NAME
script: |
extension try<T> on Class<T> {}
exampleAllowOtherCodes: true
VarAsTypeName:
parameters: none
index: 61
problemMessage: "The keyword 'var' can't be used as a type name."
analyzerCode: ParserErrorCode.VAR_AS_TYPE_NAME
script:
- "class A { Map<String, var> m; }"
exampleAllowOtherCodes: true
MissingExpressionInThrow:
parameters: none
index: 32
problemMessage: "Missing expression after 'throw'."
correctionMessage: "Add an expression after 'throw' or use 'rethrow' to throw a caught exception"
analyzerCode: ParserErrorCode.MISSING_EXPRESSION_IN_THROW
statement:
- "throw;"
MissingConstFinalVarOrType:
parameters: none
index: 33
problemMessage: "Variables must be declared using the keywords 'const', 'final', 'var' or a type name."
correctionMessage: "Try adding the name of the type of the variable or the keyword 'var'."
analyzerCode: ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
script:
- "class C { static f; }"
FunctionTypedParameterVar:
parameters: none
index: 119
problemMessage: "Function-typed parameters can't specify 'const', 'final' or 'var' in place of a return type."
correctionMessage: "Try replacing the keyword with a return type."
analyzerCode: ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR
script:
- "void f(const x()) {}"
- "void f(final x()) {}"
- "void f(var x()) {}"
exampleAllowOtherCodes: true
AbstractClassMember:
parameters: none
index: 51
problemMessage: "Members of classes can't be declared to be 'abstract'."
correctionMessage: "Try removing the 'abstract' keyword. You can add the 'abstract' keyword before the class declaration."
analyzerCode: ParserErrorCode.ABSTRACT_CLASS_MEMBER
script:
- |
abstract class C {abstract C.c();}
- |
abstract class C {abstract m();}
- |
abstract class C {abstract get m;}
- |
abstract class C {abstract set m(int x);}
AbstractExternalField:
parameters: none
index: 110
problemMessage: "Fields can't be declared both 'abstract' and 'external'."
analyzerCode: ParserErrorCode.ABSTRACT_EXTERNAL_FIELD
correctionMessage: "Try removing the 'abstract' or 'external' keyword."
script:
- "abstract class C {abstract external var f;}"
- "abstract class C {external abstract var f;}"
AbstractStaticField:
parameters: none
index: 107
problemMessage: "Static fields can't be declared 'abstract'."
analyzerCode: ParserErrorCode.ABSTRACT_STATIC_FIELD
correctionMessage: "Try removing the 'abstract' or 'static' keyword."
script:
- "abstract class C {abstract static var f;}"
AbstractExtensionField:
parameters: none
problemMessage: "Extension fields can't be declared 'abstract'."
correctionMessage: "Try removing the 'abstract' keyword."
analyzerCode: ABSTRACT_EXTENSION_FIELD
exampleAllowOtherCodes: true
script:
- "extension C on int {abstract static var f;}"
AbstractFieldInitializer:
parameters: none
problemMessage: "Abstract fields cannot have initializers."
correctionMessage: "Try removing the initializer or the 'abstract' keyword."
script:
- "abstract class C {abstract var f = 0;}"
AbstractFieldConstructorInitializer:
parameters: none
problemMessage: "Abstract fields cannot have initializers."
correctionMessage: "Try removing the field initializer or the 'abstract' keyword from the field declaration."
script:
- "abstract class C {abstract var f; C(this.f);}"
- "abstract class C {abstract var f; C() : this.f = 0;}"
AbstractLateField:
parameters: none
index: 108
problemMessage: "Abstract fields cannot be late."
analyzerCode: ParserErrorCode.ABSTRACT_LATE_FIELD
correctionMessage: "Try removing the 'abstract' or 'late' keyword."
script:
- "abstract class C {abstract late var f;}"
AbstractFinalBaseClass:
parameters: none
problemMessage: "An 'abstract' class can't be declared as both 'final' and 'base'."
correctionMessage: "Try removing either the 'final' or 'base' keyword."
analyzerCode: ParserErrorCode.ABSTRACT_FINAL_BASE_CLASS
index: 176
script:
- "abstract final base class C {}"
AbstractFinalInterfaceClass:
parameters: none
problemMessage: "An 'abstract' class can't be declared as both 'final' and 'interface'."
correctionMessage: "Try removing either the 'final' or 'interface' keyword."
analyzerCode: ParserErrorCode.ABSTRACT_FINAL_INTERFACE_CLASS
index: 50
script:
- "abstract final interface class C {}"
AbstractSealedClass:
parameters: none
problemMessage: "A 'sealed' class can't be marked 'abstract' because it's already implicitly abstract."
correctionMessage: "Try removing the 'abstract' keyword."
analyzerCode: ParserErrorCode.ABSTRACT_SEALED_CLASS
index: 132
hasPublishedDocs: true
documentation: |-
#### Description
The analyzer produces this diagnostic when a class is declared using both
the modifier `abstract` and the modifier `sealed`. Sealed classes are
implicitly abstract, so explicitly using both modifiers is not allowed.
#### Example
The following code produces this diagnostic because the class `C` is
declared using both `abstract` and `sealed`:
```dart
abstract [!sealed!] class C {}
```
#### Common fixes
If the class should be abstract but not sealed, then remove the `sealed`
modifier:
```dart
abstract class C {}
```
If the class should be both abstract and sealed, then remove the
`abstract` modifier:
```dart
sealed class C {}
```
script:
- "sealed abstract class C {}"
- "abstract sealed class C {}"
ClassInClass:
parameters: none
index: 53
problemMessage: "Classes can't be declared inside other classes."
correctionMessage: "Try moving the class to the top-level."
analyzerCode: ParserErrorCode.CLASS_IN_CLASS
script:
- "class C { class B {} }"
EnumInClass:
parameters: none
index: 74
problemMessage: "Enums can't be declared inside classes."
correctionMessage: "Try moving the enum to the top-level."
analyzerCode: ParserErrorCode.ENUM_IN_CLASS
script:
- "class Foo { enum Bar { Bar1, Bar2, Bar3 } }"
TypedefInClass:
parameters: none
index: 7
problemMessage: "Typedefs can't be declared inside classes."
correctionMessage: "Try moving the typedef to the top-level."
analyzerCode: ParserErrorCode.TYPEDEF_IN_CLASS
script:
- "abstract class C { typedef int F(int x); }"
CovariantMember:
parameters: none
index: 67
problemMessage: "Getters, setters and methods can't be declared to be 'covariant'."
correctionMessage: "Try removing the 'covariant' keyword."
analyzerCode: ParserErrorCode.COVARIANT_MEMBER
script:
- "class A { covariant get x => 0; }"
- "class A { covariant int m() => 0; }"
VarReturnType:
parameters: none
index: 12
problemMessage: "The return type can't be 'var'."
correctionMessage: "Try removing the keyword 'var', or replacing it with the name of the return type."
analyzerCode: ParserErrorCode.VAR_RETURN_TYPE
script:
- "class C { var m() {} }"
- "class C { var C() {} }"
ConstClass:
parameters: none
index: 60
problemMessage: "Classes can't be declared to be 'const'."
correctionMessage: "Try removing the 'const' keyword. If you're trying to indicate that instances of the class can be constants, place the 'const' keyword on the class' constructor(s)."
analyzerCode: ParserErrorCode.CONST_CLASS
script: "const class C {}"
ConstAndFinal:
parameters: none
index: 58
problemMessage: "Members can't be declared to be both 'const' and 'final'."
correctionMessage: "Try removing either the 'const' or 'final' keyword."
analyzerCode: ParserErrorCode.CONST_AND_FINAL
declaration:
- "class C { static const final int x = 5; }"
- "class C { static final const int x = 5; }"
- "const final int x = 5;"
- "final const int x = 5;"
ConflictingModifiers:
parameters:
String string: undocumented
String string2: undocumented
index: 59
problemMessage: "Members can't be declared to be both '#string' and '#string2'."
correctionMessage: "Try removing one of the keywords."
analyzerCode: ParserErrorCode.CONFLICTING_MODIFIERS
script:
- "class C { const var x; }"
- "class C { var const x; }"
exampleAllowOtherCodes: true
ConstFactory:
parameters: none
index: 62
problemMessage: "Only redirecting factory constructors can be declared to be 'const'."
correctionMessage: "Try removing the 'const' keyword, or replacing the body with '=' followed by a valid target."
analyzerCode: ParserErrorCode.CONST_FACTORY
script: |
class C {
const factory C() => const C.internal();
const C.internal();
}
ConstFactoryRedirectionToNonConst:
parameters: none
problemMessage: "Constant factory constructor can't delegate to a non-constant constructor."
correctionMessage: "Try redirecting to a different constructor or marking the target constructor 'const'."
analyzerCode: REDIRECT_TO_NON_CONST_CONSTRUCTOR
script:
- >-
class A {
const factory A.foo() = A.bar;
A.bar() {}
}
NonConstFactory:
parameters: none
problemMessage: "Cannot invoke a non-'const' factory where a const expression is expected."
correctionMessage: "Try using a constructor or factory that is 'const'."
analyzerCode: NOT_CONSTANT_EXPRESSION
script: |
class Foo {
Foo();
factory Foo.f() => new Foo();
}
void foo() {
const Foo.f();
}
NonConstConstructor:
parameters: none
problemMessage: "Cannot invoke a non-'const' constructor where a const expression is expected."
correctionMessage: "Try using a constructor or factory that is 'const'."
analyzerCode: NOT_CONSTANT_EXPRESSION
script: |
class Foo {
Foo();
}
void foo() {
const Foo();
}
ModifierOutOfOrder:
parameters:
String string: undocumented
String string2: undocumented
index: 56
problemMessage: "The modifier '#string' should be before the modifier '#string2'."
correctionMessage: "Try re-ordering the modifiers."
analyzerCode: ParserErrorCode.MODIFIER_OUT_OF_ORDER
script:
- "class C { factory const C() = prefix.B.foo; }"
- "class C { factory external C(); }"
- "class C { const external C(); }"
- "class C { static external f(); }"
- "class C { final static int f = 5; }"
- "class C { var static f; }"
- "var external foo; main(){}"
exampleAllowOtherCodes: true
TypeBeforeFactory:
parameters: none
index: 57
problemMessage: "Factory constructors cannot have a return type."
correctionMessage: "Try removing the type appearing before 'factory'."
analyzerCode: ParserErrorCode.TYPE_BEFORE_FACTORY
script: |
class C {
T factory C() { return new C.constructor(); }
C.constructor();
}
ConstConstructorWithBody:
parameters: none
problemMessage: "A const constructor can't have a body."
correctionMessage: "Try removing either the 'const' keyword or the body."
analyzerCode: CONST_CONSTRUCTOR_WITH_BODY
script:
- "class C { const C() {} }"
ConstMethod:
parameters: none
index: 63
problemMessage: "Getters, setters and methods can't be declared to be 'const'."
correctionMessage: "Try removing the 'const' keyword."
analyzerCode: ParserErrorCode.CONST_METHOD
script:
- "class C { const m() {} }"
CovariantAndStatic:
parameters: none
index: 66
problemMessage: "Members can't be declared to be both 'covariant' and 'static'."
correctionMessage: "Try removing either the 'covariant' or 'static' keyword."
analyzerCode: ParserErrorCode.COVARIANT_AND_STATIC
script:
- "class A {} class C { covariant static A? f; }"
- "class A {} class C { static covariant A? f; }"
DuplicatedModifier:
parameters:
Token lexeme: undocumented
index: 70
problemMessage: "The modifier '#lexeme' was already specified."
correctionMessage: "Try removing all but one occurrence of the modifier."
analyzerCode: ParserErrorCode.DUPLICATED_MODIFIER
comment: |-
Parameters:
0: the modifier that was duplicated
exampleAllowOtherCodes: true
script:
- "class C { const const m; }"
- "class C { external external f(); }"
- "class C { final final m = 5; }"
- "class C { static static var m; }"
- "class C { var var m; }"
ExternalConstructorWithFieldInitializers:
parameters: none
index: 87
problemMessage: "An external constructor can't initialize fields."
correctionMessage: "Try removing the field initializers, or removing the keyword 'external'."
analyzerCode: ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_FIELD_INITIALIZERS
script: |
class Foo {
var x = -1;
external Foo.x(this.x);
}
ExternalFactoryWithBody:
parameters: none
index: 86
problemMessage: "External factories can't have a body."
correctionMessage: "Try removing the body of the factory, or removing the keyword 'external'."
analyzerCode: ParserErrorCode.EXTERNAL_FACTORY_WITH_BODY
script:
- "class C { external factory C() {} }"
exampleAllowOtherCodes: true
ExternalFieldInitializer:
parameters: none
problemMessage: "External fields cannot have initializers."
correctionMessage: "Try removing the initializer or the 'external' keyword."
script:
- "external var f = 0;"
- "abstract class C {external var f = 0;}"
ExternalFieldConstructorInitializer:
parameters: none
problemMessage: "External fields cannot have initializers."
correctionMessage: "Try removing the field initializer or the 'external' keyword from the field declaration."
script:
- "abstract class C {external var f; C(this.f);}"
- "abstract class C {external var f; C() : this.f = 0;}"
ExternalLateField:
parameters: none
index: 109
problemMessage: "External fields cannot be late."
analyzerCode: ParserErrorCode.EXTERNAL_LATE_FIELD
correctionMessage: "Try removing the 'external' or 'late' keyword."
script:
- "external late var f;"
- "abstract class C {external late var f;}"
InitializerForStaticField:
parameters:
Name name: undocumented
problemMessage: "'#name' isn't an instance field of this class."
analyzerCode: INITIALIZER_FOR_STATIC_FIELD
script: |
class Foo {
Foo() : initializer = true { }
}
MoreThanOneSuperInitializer:
parameters: none
problemMessage: "Can't have more than one 'super' initializer."
analyzerCode: MULTIPLE_SUPER_INITIALIZERS
script:
- "class C { C.bad() : super(), super(); }"
RedirectingConstructorWithSuperInitializer:
parameters: none
problemMessage: "A redirecting constructor can't have a 'super' initializer."
analyzerCode: SUPER_IN_REDIRECTING_CONSTRUCTOR
script:
- "class C { C(); C.bad() : super(), this(); }"
- "class C { C(); C.bad() : this(), super(); }"
RedirectingConstructorWithMultipleRedirectInitializers:
parameters: none
problemMessage: "A redirecting constructor can't have more than one redirection."
analyzerCode: MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS
script:
- "class C { C(); C.bad() : this(), this(); }"
RedirectingConstructorWithAnotherInitializer:
parameters: none
problemMessage: "A redirecting constructor can't have other initializers."
# also ASSERT_IN_REDIRECTING_CONSTRUCTOR
analyzerCode: FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR
script:
- "class C { int? x; C(); C.bad() : x = 5, this(); }"
- "class C { int? x; C(); C.bad() : this(), x = 5; }"
- "class C { int? x; C(); C.bad() : assert(true), this(); }"
- "class C { int? x; C(); C.bad() : this(), assert(true); }"
SuperInitializerNotLast:
parameters: none
problemMessage: "Can't have initializers after 'super'."
analyzerCode: SUPER_INVOCATION_NOT_LAST
script:
- "class C { int x; C.bad() : super(), x = 5; }"
ExtraneousModifier:
parameters:
Token lexeme: undocumented
index: 77
problemMessage: "Can't have modifier '#lexeme' here."
correctionMessage: "Try removing '#lexeme'."
analyzerCode: ParserErrorCode.EXTRANEOUS_MODIFIER
script:
- "var abstract foo; main(){}"
- "var static foo; main(){}"
- "abstract var foo; main(){}"
- "static var foo; main(){}"
- "abstract foo; main(){}"
- "static foo; main(){}"
- "abstract enum foo {bar}"
- "abstract void foo() {}"
- "static void foo() {}"
- "abstract typedef foo();"
- "static typedef foo();"
exampleAllowOtherCodes: true
ExtraneousModifierInExtension:
parameters:
Token lexeme: undocumented
index: 98
problemMessage: "Can't have modifier '#lexeme' in an extension."
correctionMessage: "Try removing '#lexeme'."
analyzerCode: ParserErrorCode.INVALID_USE_OF_COVARIANT_IN_EXTENSION
hasPublishedDocs: true
comment: No parameters.
documentation: |-
#### Description
The analyzer produces this diagnostic when a member declared inside an
extension uses the keyword `covariant` in the declaration of a parameter.
Extensions aren't classes and don't have subclasses, so the keyword serves
no purpose.
#### Example
The following code produces this diagnostic because `i` is marked as being
covariant:
```dart
extension E on String {
void a([!covariant!] int i) {}
}
```
#### Common fixes
Remove the `covariant` keyword:
```dart
extension E on String {
void a(int i) {}
}
```
script:
- "extension on String { foo(covariant String child) {} }"
ExtraneousModifierInExtensionType:
parameters:
Token lexeme: undocumented
index: 174
problemMessage: "Can't have modifier '#lexeme' in an extension type."
correctionMessage: "Try removing '#lexeme'."
analyzerCode: ParserErrorCode.EXTRANEOUS_MODIFIER_IN_EXTENSION_TYPE
script:
- "extension type ET(String i) { foo(covariant String child) {} }"
ExtraneousModifierInPrimaryConstructor:
parameters:
Token lexeme: undocumented
index: 175
problemMessage: "Can't have modifier '#lexeme' in a primary constructor."
correctionMessage: "Try removing '#lexeme'."
analyzerCode: ParserErrorCode.EXTRANEOUS_MODIFIER_IN_PRIMARY_CONSTRUCTOR
script:
- "extension type ET(covariant String i) { }"
FinalAndCovariant:
parameters: none
index: 80
problemMessage: "Members can't be declared to be both 'final' and 'covariant'."
correctionMessage: "Try removing either the 'final' or 'covariant' keyword."
analyzerCode: ParserErrorCode.FINAL_AND_COVARIANT
script:
- "class C { covariant final f = 5; }"
- "class C { final covariant f = 5; }"
exampleAllowOtherCodes: true
FinalAndCovariantLateWithInitializer:
parameters: none
index: 101
problemMessage: "Members marked 'late' with an initializer can't be declared to be both 'final' and 'covariant'."
correctionMessage: "Try removing either the 'final' or 'covariant' keyword, or removing the initializer."
analyzerCode: ParserErrorCode.FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER
# Weak and strong doesn't matter in this instance.
script:
- "class C { covariant late final f = 5; }"
FinalAndVar:
parameters: none
index: 81
problemMessage: "Members can't be declared to be both 'final' and 'var'."
correctionMessage: "Try removing the keyword 'var'."
analyzerCode: ParserErrorCode.FINAL_AND_VAR
script:
- "class C { final var x = 5; }"
- "class C { var final x = 5; }"
StaticConstructor:
parameters: none
index: 4
problemMessage: "Constructors can't be static."
correctionMessage: "Try removing the keyword 'static'."
analyzerCode: ParserErrorCode.STATIC_CONSTRUCTOR
script:
- "class C { static C() {} }"
- "class C { static C.m() {} }"
GetterConstructor:
parameters: none
index: 103
problemMessage: "Constructors can't be a getter."
correctionMessage: "Try removing 'get'."
analyzerCode: ParserErrorCode.GETTER_CONSTRUCTOR
script:
- "class C { get C.m() {} }"
SetterConstructor:
parameters: none
index: 104
problemMessage: "Constructors can't be a setter."
correctionMessage: "Try removing 'set'."
analyzerCode: ParserErrorCode.SETTER_CONSTRUCTOR
script:
- "class C { set C.m(x) {} }"
StaticOperator:
parameters: none
index: 17
problemMessage: "Operators can't be static."
correctionMessage: "Try removing the keyword 'static'."
analyzerCode: ParserErrorCode.STATIC_OPERATOR
script:
- "class C { static operator +(int x) => x + 1; }"
BreakOutsideOfLoop:
parameters: none
index: 52
problemMessage: "A break statement can't be used outside of a loop or switch statement."
correctionMessage: "Try removing the break statement."
analyzerCode: ParserErrorCode.BREAK_OUTSIDE_OF_LOOP
script:
- "main() { break; }"
InvalidBreakTarget:
parameters:
Name name: undocumented
problemMessage: "Can't break to '#name'."
script: |
void foo() {
switch (1) {
L: case 1:
foo() {
break L;
}
}
}
BreakTargetOutsideFunction:
parameters:
Name name: undocumented
problemMessage: "Can't break to '#name' in a different function."
analyzerCode: LABEL_IN_OUTER_SCOPE
statement: |
label: while (true) {
void f() {
while (true) {
break label;
}
}
}
AnonymousBreakTargetOutsideFunction:
parameters: none
problemMessage: "Can't break to a target in a different function."
analyzerCode: LABEL_IN_OUTER_SCOPE
statement: |
while (true) {
void f() {
break;
}
}
exampleAllowOtherCodes: true
ContinueLabelInvalid:
parameters: none
problemMessage: "A 'continue' label must be on a loop or a switch member."
analyzerCode: CONTINUE_LABEL_INVALID
statement:
- "L: { for (var i in [ ]) { continue L; } }"
ContinueOutsideOfLoop:
parameters: none
index: 2
problemMessage: "A continue statement can't be used outside of a loop or switch statement."
correctionMessage: "Try removing the continue statement."
analyzerCode: ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP
script:
- "main() { continue; }"
exampleAllowOtherCodes: true
InvalidContinueTarget:
parameters:
Name name: undocumented
problemMessage: "Can't continue at '#name'."
script: |
void foo() {
switch (1) {
L: case 1:
foo() {
continue L;
}
}
}
exampleAllowOtherCodes: true
ContinueTargetOutsideFunction:
parameters:
Name name: undocumented
problemMessage: "Can't continue at '#name' in a different function."
analyzerCode: LABEL_IN_OUTER_SCOPE
statement: |
label: while (true) {
void f() {
while (true) {
continue label;
}
}
}
AnonymousContinueTargetOutsideFunction:
parameters: none
problemMessage: "Can't continue at a target in a different function."
analyzerCode: LABEL_IN_OUTER_SCOPE
statement: |
while (true) {
void f() {
continue;
}
}
exampleAllowOtherCodes: true
ContinueWithoutLabelInCase:
parameters: none
index: 64
problemMessage: "A continue statement in a switch statement must have a label as a target."
correctionMessage: "Try adding a label associated with one of the case clauses to the continue statement."
analyzerCode: ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE
script:
- "main(List<String> x) { switch (x) {case 1: continue;} }"
DuplicateLabelInSwitchStatement:
parameters:
Name name: undocumented
index: 72
problemMessage: "The label '#name' was already used in this switch statement."
correctionMessage: "Try choosing a different name for this label."
analyzerCode: ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT
comment: |-
Parameters:
0: the label that was duplicated
statement:
- "switch (0) {l1: case 0: break; l1: case 1: break;}"
LabelNotFound:
parameters:
Name name: undocumented
problemMessage: "Can't find label '#name'."
correctionMessage: "Try defining the label, or correcting the name to match an existing label."
analyzerCode: LABEL_UNDEFINED
statement:
- "switch (0) {case 0: continue L;}"
InitializedVariableInForEach:
parameters: none
index: 82
problemMessage: "The loop variable in a for-each loop can't be initialized."
correctionMessage: "Try removing the initializer, or using a different kind of loop."
analyzerCode: ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH
statement:
- "for (int a = 0 in <int>[10]) {}"
InvalidAwaitFor:
parameters: none
index: 9
problemMessage: "The keyword 'await' isn't allowed for a normal 'for' statement."
correctionMessage: "Try removing the keyword, or use a for-each statement."
analyzerCode: ParserErrorCode.INVALID_AWAIT_IN_FOR
script:
- "f() async {await for (int i = 0; i < 5; i++) {}}"
InvalidSyncModifier:
parameters: none
problemMessage: "Invalid modifier 'sync'."
correctionMessage: "Try replacing 'sync' with 'sync*'."
analyzerCode: MISSING_STAR_AFTER_SYNC
script: "main() sync {}"
InvalidVoid:
parameters: none
problemMessage: "Type 'void' can't be used here."
correctionMessage: "Try removing 'void' keyword or replace it with 'var', 'final', or a type."
analyzerCode: EXPECTED_TYPE_NAME
script:
- "class Foo extends void {}"
exampleAllowOtherCodes: true
VoidWithTypeArguments:
parameters: none
problemMessage: "Type 'void' can't have type arguments."
correctionMessage: "Try removing the type arguments."
index: 100
analyzerCode: ParserErrorCode.VOID_WITH_TYPE_ARGUMENTS
script:
- "void<int> f() {}"
# TODO(danrubel): Review where this error is generated and consider generating
# FieldInitializedOutsideDeclaringClass instead of this in some situations.
InvalidInitializer:
parameters: none
index: 90
problemMessage: "Not a valid initializer."
correctionMessage: "To initialize a field, use the syntax 'name = value'."
analyzerCode: ParserErrorCode.INVALID_INITIALIZER
script: |
class A {
int a = 0;
}
class B extends A {
B() : super.a = 42;
}
exampleAllowOtherCodes: true
FieldInitializedOutsideDeclaringClass:
parameters: none
index: 88
problemMessage: "A field can only be initialized in its declaring class"
correctionMessage: "Try passing a value into the superclass constructor, or moving the initialization into the constructor body."
analyzerCode: ParserErrorCode.FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS
script:
- "class A { int a; } class C extends A { C() : super.a = 42; }"
exampleAllowOtherCodes: true
FinalFieldNotInitialized:
parameters:
Name name: undocumented
problemMessage: "Final field '#name' is not initialized."
correctionMessage: "Try to initialize the field in the declaration or in every constructor."
analyzerCode: FINAL_NOT_INITIALIZED
script: |
class C {
final int x;
}
FinalFieldNotInitializedByConstructor:
parameters:
Name name: undocumented
problemMessage: "Final field '#name' is not initialized by this constructor."
correctionMessage: "Try to initialize the field using an initializing formal or a field initializer."
analyzerCode: FINAL_NOT_INITIALIZED_CONSTRUCTOR_1
script: |
class C {
final int x;
C(this.x) {}
C.missing() {}
}
MissingExponent:
parameters: none
problemMessage: "Numbers in exponential notation should always contain an exponent (an integer number with an optional sign)."
correctionMessage: "Make sure there is an exponent, and remove any whitespace before it."
analyzerCode: MISSING_DIGIT
script: |
main() {
var i = 1e;
}
PositionalParameterWithEquals:
parameters: none
problemMessage: "Positional optional parameters can't use ':' to specify a default value."
correctionMessage: "Try replacing ':' with '='."
analyzerCode: WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER
script: |
main() {
foo([a: 1]) => print(a);
foo(2);
}
RequiredParameterWithDefault:
parameters: none
problemMessage: "Non-optional parameters can't have a default value."
correctionMessage: "Try removing the default value or making the parameter optional."
analyzerCode: NAMED_PARAMETER_OUTSIDE_GROUP
script:
- >
main() {
foo(a: 1) => print(a);
foo(2);
}
- >
main() {
foo(a = 1) => print(a);
foo(2);
}
StackOverflow:
parameters: none
index: 19
problemMessage: "The file has too many nested expressions or statements."
correctionMessage: "Try simplifying the code."
analyzerCode: ParserErrorCode.STACK_OVERFLOW
InvalidCodePoint:
parameters: none
problemMessage: "The escape sequence starting with '\\u' isn't a valid code point."
analyzerCode: INVALID_CODE_POINT
expression:
- "'\\u{110000}'"
InvalidHexEscape:
parameters: none
index: 40
problemMessage: "An escape sequence starting with '\\x' must be followed by 2 hexadecimal digits."
analyzerCode: ParserErrorCode.INVALID_HEX_ESCAPE
expression:
- "'\\x0'"
- "'\\x0y'"
InvalidUnicodeEscapeUStarted:
parameters: none
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_U_STARTED
expression:
- "'\\u'"
InvalidUnicodeEscapeUNoBracket:
parameters: none
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:
parameters: none
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:
parameters: none
index: 126
problemMessage: "The string '\\' can't stand alone."
correctionMessage: "Try adding another backslash (\\) to escape the '\\'."
analyzerCode: ParserErrorCode.INVALID_UNICODE_ESCAPE_STARTED
exampleAllowOtherCodes: true
expression:
- |
print('Hello, World!\
');
UnexpectedDollarInString:
parameters: none
problemMessage: "A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({})."
correctionMessage: "Try adding a backslash (\\) to escape the '$'."
analyzerCode: UNEXPECTED_DOLLAR_IN_STRING
expression:
- "'$'"
- '"$"'
- "'''$'''"
- '"""$"""'
UnexpectedSeparatorInNumber:
parameters: none
problemMessage: "Digit separators ('_') in a number literal can only be placed between two digits."
correctionMessage: "Try removing the '_'."
analyzerCode: UNEXPECTED_SEPARATOR_IN_NUMBER
expression:
- '123_'
- '1.23_'
- '1_.23'
- '0x_123'
- '0x123_'
- '1_e23'
- '1e_23'
- '1.2_e3'
- '1.2e_3'
UnexpectedToken:
parameters:
Token lexeme: undocumented
problemMessage: "Unexpected token '#lexeme'."
analyzerCode: UNEXPECTED_TOKEN
script:
- "import 'b.dart' d as b;"
exampleAllowOtherCodes: true
UnexpectedTokens:
parameters: none
problemMessage: "Unexpected tokens."
analyzerCode: ParserErrorCode.UNEXPECTED_TOKENS
index: 123
script: "enum E w Foo { v; }"
LiteralWithClassAndNew:
parameters:
String string: undocumented
Token lexeme: undocumented
problemMessage: "A #string literal can't be prefixed by 'new #lexeme'."
correctionMessage: "Try removing 'new' and '#lexeme'"
analyzerCode: ParserErrorCode.LITERAL_WITH_CLASS_AND_NEW
index: 115
script:
- "var x = new Map{};"
- "var x = new Set{};"
- "var x = new List[];"
- "var x = new Map{1: 2};"
- "var x = new Set{1};"
- "var x = new List[1];"
LiteralWithClass:
parameters:
String string: undocumented
Token lexeme: undocumented
problemMessage: "A #string literal can't be prefixed by '#lexeme'."
correctionMessage: "Try removing '#lexeme'"
analyzerCode: ParserErrorCode.LITERAL_WITH_CLASS
index: 116
script:
- "var x = Map{};"
- "var x = Set{};"
- "var x = List<String>[];"
- "var x = Map{1: 2};"
- "var x = Set{1};"
- "var x = List<int>[1];"
- "var x = const Map{};"
- "var x = const Set{};"
- "var x = const List[];"
- "var x = const Map{1: 2};"
- "var x = const Set{1};"
- "var x = const List[1];"
LiteralWithNew:
parameters: none
problemMessage: "A literal can't be prefixed by 'new'."
correctionMessage: "Try removing 'new'"
analyzerCode: ParserErrorCode.LITERAL_WITH_NEW
index: 117
script:
- "var x = new <String, String>{};"
- "var x = new <String>{};"
- "var x = new {};"
- "var x = new [];"
- "var x = new <String, String>{'a': 'b'};"
- "var x = new <String>{'a'};"
- "var x = new {'a': 'b'};"
- "var x = new {'a'};"
- "var x = new ['a'];"
UnmatchedToken:
parameters:
String string: undocumented
Token lexeme: undocumented
problemMessage: "Can't find '#string' to match '#lexeme'."
analyzerCode: EXPECTED_TOKEN
script:
- "main("
- "main(){"
- "main(){[}"
exampleAllowOtherCodes: true
UnsupportedOperator:
parameters:
Token lexeme: undocumented
problemMessage: "The '#lexeme' operator is not supported."
analyzerCode: UNSUPPORTED_OPERATOR
script:
- "class C { void operator ===(x) {} }"
- "class C { void operator !==(x) {} }"
UnsupportedPrefixPlus:
parameters: none
problemMessage: "'+' is not a prefix operator."
correctionMessage: "Try removing '+'."
analyzerCode: MISSING_IDENTIFIER
expression: "+2" # No longer a valid way to write '2'
UnterminatedComment:
parameters: none
problemMessage: "Comment starting with '/*' must end with '*/'."
analyzerCode: UNTERMINATED_MULTI_LINE_COMMENT
script:
main() {
}
/*
UnterminatedString:
parameters:
String string: undocumented
String string2: undocumented
problemMessage: "String starting with #string must end with #string2."
analyzerCode: UNTERMINATED_STRING_LITERAL
script:
- >
main() {
return '
;
}
- >
main() {
return \"
;
}
- >
main() {
return r'
;
}
- >
main() {
return r\"
;
}
- >
main() => '''
- >
main() => \"\"\"
- >
main() => r'''
- >
main() => r\"\"\"
exampleAllowOtherCodes: true
UnterminatedToken:
# This is a fall-back message that shouldn't happen.
parameters: none
problemMessage: "Incomplete token."
# Note: avoid using this template, it should only be used for debugging and
# prototyping, see [diagnostics.md](
# lib/src/base/diagnostics.md#avoid-composing-messages-programmatically).
Unspecified:
parameters:
String string: undocumented
problemMessage: "#string"
AbstractNotSync:
parameters: none
problemMessage: "Abstract methods can't use 'async', 'async*', or 'sync*'."
analyzerCode: NON_SYNC_ABSTRACT_METHOD
script: |
abstract class Foo {
Future<void> bar() async;
}
exampleAllowOtherCodes: true
AwaitAsIdentifier:
parameters: none
problemMessage: "'await' can't be used as an identifier in 'async', 'async*', or 'sync*' methods."
analyzerCode: ASYNC_KEYWORD_USED_AS_IDENTIFIER
script: |
Future<void> foo() async {
int await = 1;
}
AwaitNotAsync:
parameters: none
problemMessage: "'await' can only be used in 'async' or 'async*' methods."
analyzerCode: AWAIT_IN_WRONG_CONTEXT
script: |
void foo() {
await null;
}
BuiltInIdentifierAsType:
parameters:
Token lexeme: undocumented
problemMessage: "The built-in identifier '#lexeme' can't be used as a type."
analyzerCode: BUILT_IN_IDENTIFIER_AS_TYPE
script: |
class Foo<as extends Comparable<as>> {}
exampleAllowOtherCodes: true
BuiltInIdentifierInDeclaration:
parameters:
Token lexeme: undocumented
problemMessage: "Can't use '#lexeme' as a name here."
analyzerCode: BUILT_IN_IDENTIFIER_IN_DECLARATION
script: |
class late {}
AwaitForNotAsync:
parameters: none
problemMessage: "The asynchronous for-in can only be used in functions marked with 'async' or 'async*'."
correctionMessage: "Try marking the function body with either 'async' or 'async*', or removing the 'await' before the for loop."
analyzerCode: ASYNC_FOR_IN_WRONG_CONTEXT
script: |
main(o) sync* {
await for (var e in o) {}
}
ConstructorNotSync:
parameters: none
problemMessage: "Constructor bodies can't use 'async', 'async*', or 'sync*'."
analyzerCode: NON_SYNC_CONSTRUCTOR
script: |
class Foo {
Foo() async {}
}
FactoryNotSync:
parameters: none
problemMessage: "Factory bodies can't use 'async', 'async*', or 'sync*'."
analyzerCode: NON_SYNC_FACTORY
script: |
class Foo {
Foo._();
factory Foo.x() async => new Foo._();
}
GeneratorReturnsValue:
parameters: none
problemMessage: "'sync*' and 'async*' can't return a value."
analyzerCode: RETURN_IN_GENERATOR
script: |
Iterable<int> foo() sync* {
return [42];
}
InvalidInlineFunctionType:
parameters: none
problemMessage: "Inline function types cannot be used for parameters in a generic function type."
correctionMessage: "Try changing the inline function type (as in 'int f()') to a prefixed function type using the `Function` keyword (as in 'int Function() f')."
analyzerCode: INVALID_INLINE_FUNCTION_TYPE
declaration: "typedef F = Function(int f(String x));"
SetterNotSync:
parameters: none
problemMessage: "Setters can't use 'async', 'async*', or 'sync*'."
analyzerCode: INVALID_MODIFIER_ON_SETTER
script: |
set foo(int x) async {}
YieldAsIdentifier:
parameters: none
problemMessage: "'yield' can't be used as an identifier in 'async', 'async*', or 'sync*' methods."
analyzerCode: ASYNC_KEYWORD_USED_AS_IDENTIFIER
script: |
Future<void> foo() async {
int yield = 1;
}
YieldNotGenerator:
parameters: none
problemMessage: "'yield' can only be used in 'sync*' or 'async*' methods."
analyzerCode: YIELD_IN_NON_GENERATOR
script: |
Future<int> f() => Future.value(7);
List<int> g() {
yield f();
return [];
}
OnlyTry:
parameters: none
index: 20
problemMessage: "A try block must be followed by an 'on', 'catch', or 'finally' clause."
correctionMessage: "Try adding either a catch or finally clause, or remove the try statement."
analyzerCode: ParserErrorCode.MISSING_CATCH_OR_FINALLY
statement: "try {}"
TypeAfterVar:
parameters: none
index: 89
problemMessage: "Variables can't be declared using both 'var' and a type name."
correctionMessage: "Try removing 'var.'"
analyzerCode: ParserErrorCode.VAR_AND_TYPE
script:
- "var String foo; main(){}"
exampleAllowOtherCodes: true
PositionalAfterNamedArgument:
parameters: none
problemMessage: "Place positional arguments before named arguments."
correctionMessage: "Try moving the positional argument before the named arguments, or add a name to the argument."
analyzerCode: POSITIONAL_AFTER_NAMED_ARGUMENT
ExpectedNamedArgument:
parameters: none
problemMessage: "Expected named argument."
analyzerCode: EXTRA_POSITIONAL_ARGUMENTS
script: |
// @dart=2.16
void foo({int x = 1, int y = 2}) {}
void bar() => foo(x: 42, ,);
exampleAllowOtherCodes: true
AssertAsExpression:
parameters: none
problemMessage: "`assert` can't be used as an expression."
script: |
int assert(int x) {
if (x == 0) return 42;
return assert(x-1) + 1;
}
exampleAllowOtherCodes: true
FunctionTypeDefaultValue:
parameters: none
problemMessage: "Can't have a default value in a function type."
analyzerCode: DEFAULT_VALUE_IN_FUNCTION_TYPE
script: |
void Function({dynamic obj = Object})? x;
PrivateNamedParameter:
parameters: none
problemMessage: "A named parameter can't start with an underscore ('_')."
analyzerCode: PRIVATE_OPTIONAL_PARAMETER
script: |
void foo({int? _hello}) {}
GetterWithFormals:
parameters: none
problemMessage: "A getter can't have formal parameters."
correctionMessage: "Try removing '(...)'."
analyzerCode: GETTER_WITH_PARAMETERS
script: |
int get foo(int x) => 42;
SetterWithWrongNumberOfFormals:
parameters: none
problemMessage: "A setter should have exactly one formal parameter."
analyzerCode: WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
script:
- "var set foo; main(){}"
exampleAllowOtherCodes: true
CatchSyntax:
parameters: none
index: 84
problemMessage: "'catch' must be followed by '(identifier)' or '(identifier, identifier)'."
correctionMessage: "No types are needed, the first is given by 'on', the second is always 'StackTrace'."
analyzerCode: ParserErrorCode.CATCH_SYNTAX
statement:
- "try {} catch {}"
- "try {} catch () {}"
- "try {} catch (e,) {}"
CatchSyntaxExtraParameters:
parameters: none
index: 83
problemMessage: "'catch' must be followed by '(identifier)' or '(identifier, identifier)'."
correctionMessage: "No types are needed, the first is given by 'on', the second is always 'StackTrace'."
analyzerCode: ParserErrorCode.CATCH_SYNTAX_EXTRA_PARAMETERS
statement:
- "try {} catch (e, s, x) {}"
SuperNullAware:
parameters: none
index: 18
problemMessage: "The operator '?.' cannot be used with 'super' because 'super' cannot be null."
correctionMessage: "Try replacing '?.' with '.'"
analyzerCode: ParserErrorCode.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
script: |
class Super {
Super.named();
}
class Class extends Super {
Class() : super?.named();
}
exampleAllowOtherCodes: true
NullAwareCascadeOutOfOrder:
parameters: none
index: 96
problemMessage: "The '?..' cascade operator must be first in the cascade sequence."
correctionMessage: "Try moving the '?..' operator to be the first cascade operator in the sequence."
analyzerCode: ParserErrorCode.NULL_AWARE_CASCADE_OUT_OF_ORDER
script: |
void foo(int? x) {
x
..hashCode
?..isEven;
}
exampleAllowOtherCodes: true
ConstFieldWithoutInitializer:
parameters:
Name name: undocumented
problemMessage: "The const variable '#name' must be initialized."
correctionMessage: "Try adding an initializer ('= expression') to the declaration."
analyzerCode: CONST_NOT_INITIALIZED
script:
- "var const foo; main(){}"
exampleAllowOtherCodes: true
FinalFieldWithoutInitializer:
parameters:
Name name: undocumented
problemMessage: "The final variable '#name' must be initialized."
correctionMessage: "Try adding an initializer ('= expression') to the declaration."
analyzerCode: FINAL_NOT_INITIALIZED
script:
- "var final foo; main(){}"
exampleAllowOtherCodes: true
MetadataTypeArguments:
parameters: none
index: 91
problemMessage: "An annotation can't use type arguments."
analyzerCode: ParserErrorCode.ANNOTATION_WITH_TYPE_ARGUMENTS
script: |
// @dart=2.12
class C<T> {
const C();
}
@C<int>() // Error
void foo() {}
MetadataTypeArgumentsUninstantiated:
parameters: none
index: 114
problemMessage: "An annotation with type arguments must be followed by an argument list."
analyzerCode: ParserErrorCode.ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED
script:
- "@deprecated<int> class C {}"
MetadataSpaceBeforeParenthesis:
parameters: none
index: 134
problemMessage: "Annotations can't have spaces or comments before the parenthesis."
correctionMessage: Remove any spaces or comments before the parenthesis.
analyzerCode: ParserErrorCode.ANNOTATION_SPACE_BEFORE_PARENTHESIS
script:
- >-
class Foo<T> {
const Foo();
}
@Foo<int> () var bar;
- >-
class Foo {
const Foo();
}
@Foo () class Bar {}
ConstructorNotFound:
parameters:
Name name: undocumented
problemMessage: "Couldn't find constructor '#name'."
analyzerCode: CONSTRUCTOR_NOT_FOUND
script: |
class Foo {
Foo.bar() {}
}
void baz() {
new Foo.baz();
}
ConstructorWithReturnType:
parameters: none
index: 55
problemMessage: "Constructors can't have a return type."
correctionMessage: "Try removing the return type."
analyzerCode: ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE
script:
- "class C { int C() {} }"
- "class C { void C.m() {} }"
ConstructorWithTypeParameters:
parameters: none
index: 99
problemMessage: "Constructors can't have type parameters."
analyzerCode: ParserErrorCode.TYPE_PARAMETER_ON_CONSTRUCTOR
correctionMessage: "Try removing the type parameters."
script:
- >-
class C { C<T>() {} }
- >-
class C { C.foo<T>() {} }
- >-
class C {
factory C<T>() => new C.internal();
C.internal();
}
- >-
class C {
factory C.foo<T>() => new C.internal();
C.internal();
}
ConstructorWithTypeArguments:
parameters: none
problemMessage: "A constructor invocation can't have type arguments after the constructor name."
correctionMessage: "Try removing the type arguments or placing them after the class name."
analyzerCode: ParserErrorCode.CONSTRUCTOR_WITH_TYPE_ARGUMENTS
index: 118
script:
- "class C<X> { C.foo(); } bar() { new C.foo<int>(); }"
- "class C<X> { C.foo(); } bar() { C.foo<int>(); }"
ConstructorWithWrongName:
parameters: none
problemMessage: "The name of a constructor must match the name of the enclosing class."
analyzerCode: ParserErrorCode.INVALID_CONSTRUCTOR_NAME
index: 102
script:
- >-
class A { B.foo() {} }
- >-
class A {
factory B() => new A.internal();
A.internal();
}
- >-
class A {
factory B.foo() => new A.internal();
A.internal();
}
ConstructorWithWrongNameContext:
parameters:
Name name: undocumented
problemMessage: "The name of the enclosing class is '#name'."
severity: CONTEXT
ConstructorCyclic:
parameters: none
problemMessage: "Redirecting constructors can't be cyclic."
correctionMessage: "Try to have all constructors eventually redirect to a non-redirecting constructor."
analyzerCode: RECURSIVE_CONSTRUCTOR_REDIRECT
script:
- "class C { C.foo() : this.bar(); C.bar() : this.foo(); }"
FieldInitializerOutsideConstructor:
parameters: none
index: 79
problemMessage: "Field formal parameters can only be used in a constructor."
correctionMessage: "Try removing 'this.'."
analyzerCode: ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR
hasPublishedDocs: true
script:
- "class C { void m(this.x); }"
exampleAllowOtherCodes: true
SuperParameterInitializerOutsideConstructor:
parameters: none
problemMessage: "Super-initializer formal parameters can only be used in generative constructors."
correctionMessage: "Try removing 'super.'."
script: |
class A {
A(int x);
}
class C extends A {
C(super._);
factory C.r2(super._) = C; // Error.
}
exampleAllowOtherCodes: true
RedirectionTargetNotFound:
parameters:
Name name: undocumented
problemMessage: "Redirection constructor target not found: '#name'"
analyzerCode: REDIRECT_TO_MISSING_CONSTRUCTOR
script: |
class Class {
factory Class.a() = Class.nonexisting;
}
CyclicTypedef:
parameters:
Name name: undocumented
problemMessage: "The typedef '#name' has a reference to itself."
analyzerCode: TYPE_ALIAS_CANNOT_REFERENCE_ITSELF
script: |
typedef Foo = Foo;
TypeNotFound:
parameters:
Name name: undocumented
problemMessage: "Type '#name' not found."
analyzerCode: UNDEFINED_CLASS
script: |
Bar? foo() {
return null;
}
NameNotFound:
parameters:
Name name: undocumented
problemMessage: "Undefined name '#name'."
analyzerCode: UNDEFINED_NAME
script: |
void foo() => bar;
MemberNotFound:
parameters:
Name name: undocumented
problemMessage: "Member not found: '#name'."
analyzerCode: UNDEFINED_GETTER
script: |
class Foo {}
void bar() => Foo.baz();
GetterNotFound:
parameters:
Name name: undocumented
problemMessage: "Getter not found: '#name'."
analyzerCode: UNDEFINED_GETTER
script:
void set onlySetter(value) {}
void foo() => print(onlySetter);
SetterNotFound:
parameters:
Name name: undocumented
problemMessage: "Setter not found: '#name'."
analyzerCode: UNDEFINED_SETTER
script: |
void x() {
foo = 42;
}
MethodNotFound:
parameters:
Name name: undocumented
problemMessage: "Method not found: '#name'."
analyzerCode: UNDEFINED_METHOD
script: |
void foo() => z("Hello, World!");
CandidateFound:
parameters: none
problemMessage: "Found this candidate, but the arguments don't match."
severity: CONTEXT
CandidateFoundIsDefaultConstructor:
parameters:
Name name: undocumented
problemMessage: "The class '#name' has a constructor that takes no arguments."
severity: CONTEXT
TooFewArguments:
parameters:
int count: undocumented
int count2: undocumented
problemMessage: "Too few positional arguments: #count required, #count2 given."
analyzerCode: NOT_ENOUGH_REQUIRED_ARGUMENTS
script: |
void foo(int i) {}
void bar() {
foo();
}
TooManyArguments:
parameters:
int count: undocumented
int count2: undocumented
problemMessage: "Too many positional arguments: #count allowed, but #count2 found."
correctionMessage: "Try removing the extra positional arguments."
analyzerCode: EXTRA_POSITIONAL_ARGUMENTS
script: |
void foo(int i) {}
void bar() {
foo(1, 2);
}
NoSuchNamedParameter:
parameters:
Name name: undocumented
problemMessage: "No named parameter with the name '#name'."
analyzerCode: UNDEFINED_NAMED_PARAMETER
script: |
void foo(int i) => i.toString(hello: 42);
AbstractClassInstantiation:
parameters:
Name name: undocumented
problemMessage: "The class '#name' is abstract and can't be instantiated."
analyzerCode: NEW_WITH_ABSTRACT_CLASS
script: |
abstract class Foo {}
main() { new Foo(); }
EnumInstantiation:
parameters: none
problemMessage: "Enums can't be instantiated."
analyzerCode: INSTANTIATE_ENUM
script: |
enum E {
a, b, c;
factory E.x() {
return const E();
}
}
AbstractRedirectedClassInstantiation:
parameters:
Name name: undocumented
problemMessage: "Factory redirects to class '#name', which is abstract and can't be instantiated."
analyzerCode: FACTORY_REDIRECTS_TO_ABSTRACT_CLASS
script: |
abstract class A {
A._();
factory A() = B;
}
abstract class B extends A {
B() : super._();
}
MissingImplementationNotAbstract:
parameters:
Name name: undocumented
Names names: undocumented
problemMessage: |
The non-abstract class '#name' is missing implementations for these members:
#names
correctionMessage: |
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
analyzerCode: CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
script:
- "class C {foo();}"
MissingImplementationCause:
parameters:
Name name: undocumented
problemMessage: "'#name' is defined here."
severity: CONTEXT
InterfaceCheck:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "The implementation of '#name' in the non-abstract class '#name2' does not conform to its interface."
script: |
class A {
void foo() {}
}
abstract class B extends A {
void foo([a]);
}
class C extends B {}
NamedMixinOverride:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "The mixin application class '#name' introduces an erroneous override of '#name2'."
script: |
class Super {
void extendedConcreteMixedInConcreteMethod() {}
}
mixin class Mixin {
void extendedConcreteMixedInConcreteMethod(int i) {}
}
class NamedMixin = Super with Mixin;
ImplicitMixinOverride:
parameters:
Name name: undocumented
Name name2: undocumented
Name name3: undocumented
problemMessage: "Applying the mixin '#name' to '#name2' introduces an erroneous override of '#name3'."
script: |
abstract class Super {
String get extendedGetterMixedInField => '';
}
mixin Mixin {
int extendedGetterMixedInField = 0;
}
abstract class Class extends Super with Mixin { }
ListLiteralTooManyTypeArguments:
parameters: none
problemMessage: "List literal requires exactly one type argument."
analyzerCode: EXPECTED_ONE_LIST_TYPE_ARGUMENTS
script: |
void foo() {
var x = <int, int>[];
}
SetOrMapLiteralTooManyTypeArguments:
parameters: none
problemMessage: "A set or map literal requires exactly one or two type arguments, respectively."
script: |
var x = <int, int, int>{};
LoadLibraryTakesNoArguments:
parameters: none
problemMessage: "'loadLibrary' takes no arguments."
analyzerCode: LOAD_LIBRARY_TAKES_NO_ARGUMENTS
script:
main.dart: |
import "lib.dart" deferred as lib;
void main() {
lib.loadLibrary(10);
}
lib.dart: ""
TypeArgumentMismatch:
parameters:
int count: undocumented
problemMessage: "Expected #count type arguments."
analyzerCode: WRONG_NUMBER_OF_TYPE_ARGUMENTS
script: |
void foo() {
new List<int, int>.filled(0, 42);
}
NotAType:
parameters:
Name name: undocumented
problemMessage: "'#name' isn't a type."
analyzerCode: NOT_A_TYPE
script:
main.dart: |
import 'lib.dart' as prefix;
void foo() {
prefix.NonExisting? e;
}
lib.dart: ""
NotATypeContext:
parameters: none
problemMessage: "This isn't a type."
severity: CONTEXT
NotAPrefixInTypeAnnotation:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "'#name.#name2' can't be used as a type because '#name' doesn't refer to an import prefix."
analyzerCode: NOT_A_TYPE
declaration:
- |
class C<T> {
T.String method() {}
}
- |
class C<T> {
T.String field;
}
FastaUsageShort:
parameters: none
problemMessage: |
Frequently used options:
-o <file> Generate the output into <file>.
-h Display this message (add -v for information about all options).
FastaUsageLong:
# TODO(ahe): Consider if the reference to platform.dill needs to change below?
parameters: none
problemMessage: |
Supported options:
-o <file>, --output=<file>
Generate the output into <file>.
-h, /h, /?, --help
Display this message (add -v for information about all options).
-v, --verbose
Display verbose information.
-Dname
-Dname=value
Define an environment variable in the compile-time environment.
--no-defines
Ignore all -D options and leave environment constants unevaluated.
--
Stop option parsing, the rest of the command line is assumed to be
file names or arguments to the Dart program.
--packages=<file>
Use package resolution configuration <file>, which should contain a mapping
of package names to paths.
--platform=<file>
Read the SDK platform from <file>, which should be in Dill/Kernel IR format
and contain the Dart SDK.
--target=dart2js|dart2js_server|dart2wasm|dart2wasm_js_compatibility|dart_runner|dartdevc|flutter|flutter_runner|none|vm
Specify the target configuration.
--enable-asserts
Check asserts in initializers during constant evaluation.
--verify
Check that the generated output is free of various problems. This is mostly
useful for developers of this compiler or Kernel transformations.
--dump-ir
Print compiled libraries in Kernel source notation.
--omit-platform
Exclude the platform from the serialized dill file.
--exclude-source
Do not include source code in the dill file.
--compile-sdk=<sdk>
Compile the SDK from scratch instead of reading it from a .dill file
(see --platform).
--sdk=<sdk>
Location of the SDK sources for use when compiling additional platform
libraries.
--single-root-scheme=String
--single-root-base=<dir>
Specify a custom URI scheme and a location on disk where such URIs are
mapped to.
When specified, the compiler can be invoked with inputs using the custom
URI scheme. The compiler can ignore the exact location of files on disk
and as a result to produce output that is independent of the absolute
location of files on disk. This is mostly useful for integrating with
build systems.
--fatal=errors
--fatal=warnings
Makes messages of the given kinds fatal, that is, immediately stop the
compiler with a non-zero exit-code. In --verbose mode, also display an
internal stack trace from the compiler. Multiple kinds can be separated by
commas, for example, --fatal=errors,warnings.
--fatal-skip=<number>
--fatal-skip=trace
Skip this many messages that would otherwise be fatal before aborting the
compilation. Default is 0, which stops at the first message. Specify
'trace' to print a stack trace for every message without stopping.
--enable-experiment=<flag>
Enable or disable an experimental flag, used to guard features currently
in development. Prefix an experiment name with 'no-' to disable it.
Multiple experiments can be separated by commas.
FastaCLIArgumentRequired:
parameters:
Name name: undocumented
problemMessage: "Expected value after '#name'."
NamedFunctionExpression:
parameters: none
problemMessage: "A function expression can't have a name."
analyzerCode: NAMED_FUNCTION_EXPRESSION
script: |
var x = void f<T>(T t) {};
NativeClauseShouldBeAnnotation:
parameters: none
index: 23
problemMessage: "Native clause in this form is deprecated."
correctionMessage: "Try removing this native clause and adding @native() or @native('native-name') before the declaration."
analyzerCode: ParserErrorCode.NATIVE_CLAUSE_SHOULD_BE_ANNOTATION
InternalProblemUnhandled:
parameters:
String string: undocumented
String string2: undocumented
problemMessage: "Unhandled #string in #string2."
severity: INTERNAL_PROBLEM
InternalProblemUnimplemented:
parameters:
String string: undocumented
problemMessage: "Unimplemented #string."
severity: INTERNAL_PROBLEM
InternalProblemUnexpected:
parameters:
String string: undocumented
String string2: undocumented
problemMessage: "Expected '#string', but got '#string2'."
severity: INTERNAL_PROBLEM
InternalProblemUnsupported:
parameters:
Name name: undocumented
problemMessage: "Unsupported operation: '#name'."
severity: INTERNAL_PROBLEM
InternalProblemNotFound:
parameters:
Name name: undocumented
problemMessage: "Couldn't find '#name'."
severity: INTERNAL_PROBLEM
InternalProblemNotFoundIn:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "Couldn't find '#name' in '#name2'."
severity: INTERNAL_PROBLEM
InternalProblemPrivateConstructorAccess:
parameters:
Name name: undocumented
problemMessage: "Can't access private constructor '#name'."
severity: INTERNAL_PROBLEM
InternalProblemConstructorNotFound:
parameters:
Name name: undocumented
Uri uri: undocumented
problemMessage: "No constructor named '#name' in '#uri'."
severity: INTERNAL_PROBLEM
InternalProblemExtendingUnmodifiableScope:
parameters: none
problemMessage: "Can't extend an unmodifiable scope."
severity: INTERNAL_PROBLEM
InternalProblemPreviousTokenNotFound:
parameters: none
problemMessage: "Couldn't find previous token."
severity: INTERNAL_PROBLEM
InternalProblemStackNotEmpty:
parameters:
Name name: undocumented
String string: undocumented
problemMessage: "#name.stack isn't empty:\n #string"
severity: INTERNAL_PROBLEM
InternalProblemAlreadyInitialized:
parameters: none
problemMessage: "Attempt to set initializer on field without initializer."
severity: INTERNAL_PROBLEM
InternalProblemBodyOnAbstractMethod:
parameters: none
problemMessage: "Attempting to set body on abstract method."
severity: INTERNAL_PROBLEM
InternalProblemMissingContext:
parameters: none
problemMessage: "Compiler cannot run without a compiler context."
correctionMessage: "Are calls to the compiler wrapped in CompilerContext.runInContext?"
severity: INTERNAL_PROBLEM
InternalProblemProvidedBothCompileSdkAndSdkSummary:
parameters: none
problemMessage: "The compileSdk and sdkSummary options are mutually exclusive"
severity: INTERNAL_PROBLEM
InternalProblemUriMissingScheme:
parameters:
Uri uri: undocumented
problemMessage: "The URI '#uri' has no scheme."
severity: INTERNAL_PROBLEM
InternalProblemContextSeverity:
parameters:
String string: undocumented
problemMessage: "Non-context message has context severity: #string"
severity: INTERNAL_PROBLEM
InternalProblemVerificationError:
parameters:
String string: undocumented
problemMessage: |
Verification of the generated program failed:
#string
severity: INTERNAL_PROBLEM
VerificationErrorOriginContext:
parameters: none
problemMessage: "The node most likely is taken from here by a transformer."
severity: CONTEXT
InternalProblemDebugAbort:
parameters:
Name name: undocumented
String string: undocumented
problemMessage: "Compilation aborted due to fatal '#name' at:\n#string"
severity: INTERNAL_PROBLEM
InternalProblemLabelUsageInVariablesDeclaration:
parameters: none
problemMessage: "Unexpected usage of label inside declaration of variables."
severity: INTERNAL_PROBLEM
InternalProblemUnsupportedNullability:
parameters:
String string: undocumented
Type type: undocumented
problemMessage: "Unsupported nullability value '#string' on type '#type'."
severity: INTERNAL_PROBLEM
InternalProblemOmittedTypeNameInConstructorReference:
parameters: none
problemMessage: "Unsupported omission of the type name in a constructor reference outside of an enum element declaration."
severity: INTERNAL_PROBLEM
IncrementalCompilerIllegalParameter:
parameters:
String string: undocumented
problemMessage: "Illegal parameter name '#string' found during expression compilation."
IncrementalCompilerIllegalTypeParameter:
parameters:
String string: undocumented
problemMessage: "Illegal type parameter name '#string' found during expression compilation."
DebugTrace:
parameters:
Name name: undocumented
String string: undocumented
problemMessage: "Fatal '#name' at:\n#string"
severity: IGNORED
MissingPrefixInDeferredImport:
parameters: none
index: 30
problemMessage: "Deferred imports should have a prefix."
correctionMessage: "Try adding a prefix to the import by adding an 'as' clause."
analyzerCode: ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT
script:
main.dart: |
import 'lib.dart' deferred;
lib.dart: ""
DeferredAfterPrefix:
parameters: none
index: 68
problemMessage: "The deferred keyword should come immediately before the prefix ('as' clause)."
correctionMessage: "Try moving the deferred keyword before the prefix."
analyzerCode: ParserErrorCode.DEFERRED_AFTER_PREFIX
script:
main.dart: |
import "lib.dart" as foo deferred;
lib.dart: ""
DuplicateDeferred:
parameters: none
index: 71
problemMessage: "An import directive can only have one 'deferred' keyword."
correctionMessage: "Try removing all but one 'deferred' keyword."
analyzerCode: ParserErrorCode.DUPLICATE_DEFERRED
script:
main.dart: |
import "lib.dart" deferred as foo deferred;
lib.dart: ""
DeferredTypeAnnotation:
parameters:
Type type: undocumented
Name name: undocumented
problemMessage: "The type '#type' is deferred loaded via prefix '#name' and can't be used as a type annotation."
correctionMessage: "Try removing 'deferred' from the import of '#name' or use a supertype of '#type' that isn't deferred."
analyzerCode: TYPE_ANNOTATION_DEFERRED_CLASS
script:
main.dart: |
import 'lib.dart' deferred as lib;
void foo(Object x) {
x as lib.C;
}
lib.dart: |
class C {}
DuplicatePrefix:
parameters: none
index: 73
problemMessage: "An import directive can only have one prefix ('as' clause)."
correctionMessage: "Try removing all but one prefix."
analyzerCode: ParserErrorCode.DUPLICATE_PREFIX
script:
main.dart: |
import "lib.dart" as foo as bar;
lib.dart: ""
PrefixAfterCombinator:
parameters: none
index: 6
problemMessage: "The prefix ('as' clause) should come before any show/hide combinators."
correctionMessage: "Try moving the prefix before the combinators."
analyzerCode: ParserErrorCode.PREFIX_AFTER_COMBINATOR
script:
main.dart: |
import "lib.dart" show Foo hide Foo as Foo;
lib.dart: ""
DuplicatedExport:
parameters:
Name name: undocumented
Uri uri: undocumented
Uri uri2: undocumented
problemMessage: "'#name' is exported from both '#uri' and '#uri2'."
analyzerCode: AMBIGUOUS_EXPORT
script:
lib1.dart: "class A {}"
lib2.dart: "class A {}"
main.dart: "export 'lib1.dart'; export 'lib2.dart';"
DuplicatedImport:
parameters:
Name name: undocumented
Uri uri: undocumented
Uri uri2: undocumented
problemMessage: "'#name' is imported from both '#uri' and '#uri2'."
analyzerCode: AMBIGUOUS_IMPORT
script:
lib1.dart: "class A {}"
lib2.dart: "class A {}"
main.dart: "import 'lib1.dart'; import 'lib2.dart'; A a;"
CyclicClassHierarchy:
parameters:
Name name: undocumented
problemMessage: "'#name' is a supertype of itself."
analyzerCode: RECURSIVE_INTERFACE_INHERITANCE
script:
- |
class A extends B {}
class B extends A {}
- |
class A implements B {}
class B implements A {}
- "class C = Object with C;"
- "class C extends C {}"
- "class C implements C {}"
exampleAllowMultipleReports: true
ExtendingEnum:
parameters:
Name name: undocumented
problemMessage: "'#name' is an enum and can't be extended or implemented."
analyzerCode: EXTENDS_ENUM
script: |
enum Foo { a, b, c; }
abstract class Bar extends Foo {}
exampleAllowOtherCodes: true
ExtendingRestricted:
parameters:
Name name: undocumented
problemMessage: "'#name' is restricted and can't be extended or implemented."
analyzerCode: EXTENDS_DISALLOWED_CLASS
script: |
abstract class Foo extends String {}
exampleAllowOtherCodes: true
NoUnnamedConstructorInObject:
parameters: none
problemMessage: "'Object' has no unnamed constructor."
IllegalAsyncGeneratorReturnType:
parameters: none
problemMessage: "Functions marked 'async*' must have a return type assignable to 'Stream'."
analyzerCode: ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE
script:
- >-
int g() async* {
yield 0;
}
IllegalAsyncGeneratorVoidReturnType:
parameters: none
problemMessage: "Functions marked 'async*' can't have return type 'void'."
script:
- >-
void g() async* {
}
IllegalAsyncReturnType:
parameters: none
problemMessage: "Functions marked 'async' must have a return type assignable to 'Future'."
analyzerCode: ILLEGAL_ASYNC_RETURN_TYPE
script:
- >-
int f() async {
return 0;
}
IllegalSyncGeneratorReturnType:
parameters: none
problemMessage: "Functions marked 'sync*' must have a return type assignable to 'Iterable'."
analyzerCode: ILLEGAL_SYNC_GENERATOR_RETURN_TYPE
script:
- >-
int g() sync* {
yield 0;
}
IllegalSyncGeneratorVoidReturnType:
parameters: none
problemMessage: "Functions marked 'sync*' can't have return type 'void'."
script:
- >-
void g() sync* {
}
IllegalMixinDueToConstructors:
# a class with a constructor is used as a mixin
parameters:
Name name: undocumented
problemMessage: "Can't use '#name' as a mixin because it has constructors."
analyzerCode: MIXIN_DECLARES_CONSTRUCTOR # CompileTimeErrorCode
script: |
// @dart=2.19
class B with Error {}
MixinDeclaresConstructor:
# a mixin declaration contains a constructor declaration
parameters: none
index: 95
problemMessage: "Mixins can't declare constructors."
analyzerCode: ParserErrorCode.MIXIN_DECLARES_CONSTRUCTOR
script: |
mixin M {
const M();
}
IllegalMixinDueToConstructorsCause:
parameters:
Name name: undocumented
problemMessage: "This constructor prevents using '#name' as a mixin."
severity: CONTEXT
ExtensionDeclaresAbstractMember:
parameters: none
index: 94
problemMessage: "Extensions can't declare abstract members."
correctionMessage: "Try providing an implementation for the member."
script: |
extension E on int {
void method();
}
analyzerCode: ParserErrorCode.EXTENSION_DECLARES_ABSTRACT_MEMBER
comment: No parameters.
documentation: |-
#### Description
The analyzer produces this diagnostic when an abstract declaration is
declared in an extension. Extensions can declare only concrete members.
#### Example
The following code produces this diagnostic because the method `a` doesn't
have a body:
```dart
extension E on String {
int [!a!]();
}
```
#### Common fixes
Either provide an implementation for the member or remove it.
hasPublishedDocs: true
ExtensionTypeDeclaresAbstractMember:
parameters: none
problemMessage: "Extension types can't declare abstract members."
correctionMessage: "Try providing an implementation for the member."
analyzerCode: EXTENSION_TYPE_WITH_ABSTRACT_MEMBER
script: |
extension type ET(int id) {
void method();
}
ExtensionDeclaresConstructor:
parameters: none
index: 92
problemMessage: "Extensions can't declare constructors."
correctionMessage: "Try removing the constructor declaration."
script: |
extension E on int {
E();
}
analyzerCode: ParserErrorCode.EXTENSION_DECLARES_CONSTRUCTOR
comment: No parameters.
documentation: |-
#### Description
The analyzer produces this diagnostic when a constructor declaration is
found in an extension. It isn't valid to define a constructor because
extensions aren't classes, and it isn't possible to create an instance of
an extension.
#### Example
The following code produces this diagnostic because there is a constructor
declaration in `E`:
```dart
extension E on String {
[!E!]() : super();
}
```
#### Common fixes
Remove the constructor or replace it with a static method.
hasPublishedDocs: true
ExtensionDeclaresInstanceField:
parameters: none
problemMessage: "Extensions can't declare instance fields"
correctionMessage: "Try removing the field declaration or making it a static field"
analyzerCode: EXTENSION_DECLARES_INSTANCE_FIELD
script: |
extension E on int {
int? field;
}
ExtensionAugmentationHasOnClause:
parameters: none
index: 93
problemMessage: "Extension augmentations can't have 'on' clauses."
correctionMessage: "Try removing the 'on' clause."
analyzerCode: ParserErrorCode.EXTENSION_AUGMENTATION_HAS_ON_CLAUSE
script: |
augment extension E on int {}
comment: No parameters.
ExtensionTypeDeclaresInstanceField:
parameters: none
problemMessage: "Extension types can't declare instance fields"
correctionMessage: "Try removing the field declaration or making it a static field"
analyzerCode: EXTENSION_TYPE_DECLARES_INSTANCE_FIELD
script: |
extension type ET(int id) {
int? field;
}
StaticConflictsWithInstance:
parameters:
Name name: undocumented
problemMessage: "Static property '#name' conflicts with instance property of the same name."
analyzerCode: CONFLICTS_WITH_MEMBER
script: |
class A {
void set foo(_) {}
static int get foo => 42;
}
StaticConflictsWithInstanceCause:
parameters:
Name name: undocumented
problemMessage: "Conflicting instance property '#name'."
severity: CONTEXT
InstanceConflictsWithStatic:
parameters:
Name name: undocumented
problemMessage: "Instance property '#name' conflicts with static property of the same name."
analyzerCode: CONFLICTS_WITH_MEMBER
script: |
class A {
static void set foo(_) {}
int get foo => 42;
}
InstanceConflictsWithStaticCause:
parameters:
Name name: undocumented
problemMessage: "Conflicting static property '#name'."
severity: CONTEXT
SetterConflictsWithDeclaration:
parameters:
Name name: undocumented
problemMessage: "The setter conflicts with declaration '#name'."
analyzerCode: CONFLICTS_WITH_MEMBER
script: |
class Foo {}
set Foo(_) {}
SetterConflictsWithDeclarationCause:
parameters:
Name name: undocumented
problemMessage: "Conflicting declaration '#name'."
severity: CONTEXT
ConstructorConflictsWithMember:
parameters:
Name name: undocumented
problemMessage: "The constructor conflicts with member '#name'."
analyzerCode: CONFLICTS_WITH_MEMBER
script: |
class A {
static int get foo => 42;
A.foo();
}
ConstructorConflictsWithMemberCause:
parameters:
Name name: undocumented
problemMessage: "Conflicting member '#name'."
severity: CONTEXT
FactoryConflictsWithMember:
parameters:
Name name: undocumented
problemMessage: "The factory conflicts with member '#name'."
analyzerCode: CONFLICTS_WITH_MEMBER
script: |
class A {
static int get foo => 42;
factory A.foo() => throw '';
}
FactoryConflictsWithMemberCause:
parameters:
Name name: undocumented
problemMessage: "Conflicting member '#name'."
severity: CONTEXT
MemberConflictsWithConstructor:
parameters:
Name name: undocumented
problemMessage: "The member conflicts with constructor '#name'."
analyzerCode: CONFLICTS_WITH_MEMBER
script: |
class A {
A.foo();
static void foo() {}
}
MemberConflictsWithConstructorCause:
parameters:
Name name: undocumented
problemMessage: "Conflicting constructor '#name'."
severity: CONTEXT
MemberConflictsWithFactory:
parameters:
Name name: undocumented
problemMessage: "The member conflicts with factory '#name'."
analyzerCode: CONFLICTS_WITH_MEMBER
script: |
class A {
factory A.foo() => throw '';
static void foo() {}
}
MemberConflictsWithFactoryCause:
parameters:
Name name: undocumented
problemMessage: "Conflicting factory '#name'."
severity: CONTEXT
DeclarationConflictsWithSetter:
parameters:
Name name: undocumented
problemMessage: "The declaration conflicts with setter '#name'."
analyzerCode: CONFLICTS_WITH_MEMBER
script: |
void set foo(_) {}
void foo() {}
DeclarationConflictsWithSetterCause:
parameters:
Name name: undocumented
problemMessage: "Conflicting setter '#name'."
severity: CONTEXT
ConflictsWithImplicitSetter:
parameters:
Name name: undocumented
problemMessage: "Conflicts with the implicit setter of the field '#name'."
analyzerCode: CONFLICTS_WITH_MEMBER
script: |
int? foo;
void set foo(_) {}
ConflictsWithImplicitSetterCause:
parameters:
Name name: undocumented
problemMessage: "Field '#name' with the implicit setter."
severity: CONTEXT
ConflictsWithTypeParameter:
parameters:
Name name: undocumented
problemMessage: "Conflicts with type variable '#name'."
analyzerCode: CONFLICTING_TYPE_VARIABLE_AND_MEMBER
script: |
enum E2<values> {
element;
}
ConflictsWithTypeParameterCause:
parameters: none
problemMessage: "This is the type variable."
severity: CONTEXT
ExtensionMemberConflictsWithObjectMember:
parameters:
Name name: undocumented
problemMessage: "This extension member conflicts with Object member '#name'."
script:
extension Extension on String {
int get noSuchMethod => 42;
}
DeclaredMemberConflictsWithInheritedMember:
parameters: none
problemMessage: "Can't declare a member that conflicts with an inherited one."
analyzerCode: DECLARED_MEMBER_CONFLICTS_WITH_INHERITED
script:
- >-
class A {
var foo;
}
class B extends A {
foo() {}
}
- >-
abstract class A {
get foo;
}
class B implements A {
foo() {}
}
- >-
class A {
foo() {}
}
class B extends A {
var foo;
}
- >-
abstract class A {
foo();
}
class B implements A {
var foo;
}
DeclaredMemberConflictsWithInheritedMemberCause:
parameters: none
problemMessage: "This is the inherited member."
severity: CONTEXT
DeclaredMemberConflictsWithInheritedMembersCause:
parameters: none
problemMessage: "This is one of the inherited members."
severity: CONTEXT
DeclaredMemberConflictsWithOverriddenMembersCause:
parameters: none
problemMessage: "This is one of the overridden members."
severity: CONTEXT
InheritedMembersConflict:
parameters: none
problemMessage: "Can't inherit members that conflict with each other."
analyzerCode: CONFLICTS_WITH_INHERITED_MEMBER
script:
- >-
class A {
foo() {}
}
abstract class B {
get foo;
}
abstract class C extends A implements B {}
- >-
class A {
var foo;
}
abstract class B {
foo();
}
abstract class C extends A implements B {}
- >-
class A {
get foo => 0;
}
abstract class B {
foo();
}
abstract class C extends A implements B {}
InheritedMembersConflictCause1:
parameters: none
problemMessage: "This is one inherited member."
severity: CONTEXT
InheritedMembersConflictCause2:
parameters: none
problemMessage: "This is the other inherited member."
severity: CONTEXT
IllegalMixin:
parameters:
Name name: undocumented
problemMessage: "The type '#name' can't be mixed in."
analyzerCode: ILLEGAL_MIXIN
script: |
class SuperClass {}
mixin Mixin<T> {}
class Class<T, M extends Mixin<T>> extends SuperClass with M {}
exampleAllowOtherCodes: true
OverrideTypeParametersMismatch:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "Declared type variables of '#name' doesn't match those on overridden method '#name2'."
analyzerCode: INVALID_METHOD_OVERRIDE_TYPE_PARAMETERS
script: |
class Super {
void foo<X>() {}
}
class Sub extends Super {
void foo<X, Y>() {}
}
OverrideTypeParametersBoundMismatch:
parameters:
Type type: undocumented
Name name: undocumented
Name name2: undocumented
Type type2: undocumented
Name name3: undocumented
problemMessage: "Declared bound '#type' of type variable '#name' of '#name2' doesn't match the bound '#type2' on overridden method '#name3'."
script: |
class Super {
void foo<X extends String>() {}
}
class Sub extends Super {
void foo<X extends bool>() {}
}
OverriddenMethodCause:
parameters:
Name name: undocumented
problemMessage: "This is the overridden method ('#name')."
severity: CONTEXT
OverrideMismatchNamedParameter:
parameters:
Name name: undocumented
Name name2: undocumented
Name name3: undocumented
problemMessage: "The method '#name' doesn't have the named parameter '#name2' of overridden method '#name3'."
analyzerCode: INVALID_OVERRIDE_NAMED
script: |
abstract class A {
int foo({int x = 0}) => x + 42;
}
class B implements A {
int foo({int y = 0}) => y + 42;
}
OverrideFewerNamedArguments:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "The method '#name' has fewer named arguments than those of overridden method '#name2'."
analyzerCode: INVALID_OVERRIDE_NAMED
script: |
abstract class A {
int foo({int x = 0, int y = 0}) => x + y + 42;
}
class B implements A {
int foo({int x = 0}) => x + 42;
}
OverrideFewerPositionalArguments:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "The method '#name' has fewer positional arguments than those of overridden method '#name2'."
analyzerCode: INVALID_OVERRIDE_POSITIONAL
script: |
abstract class A {
int foo(int x, int y) => x + y + 42;
}
class B implements A {
int foo(int x) => x + 42;
}
OverrideMoreRequiredArguments:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "The method '#name' has more required arguments than those of overridden method '#name2'."
analyzerCode: INVALID_OVERRIDE_REQUIRED
script: |
abstract class A {
int foo(int x) => x + 42;
}
class B implements A {
int foo(int x, int y) => x + y + 42;
}
OverrideTypeMismatchParameter:
parameters:
Name name: undocumented
Name name2: undocumented
Type type: undocumented
Type type2: undocumented
Name name3: undocumented
problemMessage: "The parameter '#name' of the method '#name2' has type '#type', which does not match the corresponding type, '#type2', in the overridden method, '#name3'."
correctionMessage: "Change to a supertype of '#type2', or, for a covariant parameter, a subtype."
analyzerCode: INVALID_METHOD_OVERRIDE
script: |
abstract class A {
int foo(int x) => x + 42;
}
class B implements A {
int foo(String x) => x.length + 42;
}
OverrideTypeMismatchReturnType:
parameters:
Name name: undocumented
Type type: undocumented
Type type2: undocumented
Name name2: undocumented
problemMessage: "The return type of the method '#name' is '#type', which does not match the return type, '#type2', of the overridden method, '#name2'."
correctionMessage: "Change to a subtype of '#type2'."
analyzerCode: INVALID_METHOD_OVERRIDE
script: |
abstract class A {
int foo() => 42;
}
class B implements A {
String foo() => "42";
}
OverrideTypeMismatchSetter:
parameters:
Name name: undocumented
Type type: undocumented
Type type2: undocumented
Name name2: undocumented
problemMessage: "The field '#name' has type '#type', which does not match the corresponding type, '#type2', in the overridden setter, '#name2'."
analyzerCode: INVALID_METHOD_OVERRIDE
script: |
abstract class A {
void set x(Object? y);
}
class B implements A {
int? x;
}
OverrideMismatchRequiredNamedParameter:
parameters:
Name name: undocumented
Name name2: undocumented
Name name3: undocumented
problemMessage: "The required named parameter '#name' in method '#name2' is not required in overridden method '#name3'."
script: |
abstract class A {
method({int? a});
}
abstract class B implements A {
method({required int? a});
}
InvalidGetterSetterType:
parameters:
Type type: undocumented
Name name: undocumented
Type type2: undocumented
Name name2: undocumented
problemMessage: "The type '#type' of the getter '#name' is not a subtype of the type '#type2' of the setter '#name2'."
script: |
//@dart=3.5
abstract class A {
num get property;
set property(int i);
}
InvalidGetterSetterTypeGetterInherited:
parameters:
Type type: undocumented
Name name: undocumented
Type type2: undocumented
Name name2: undocumented
problemMessage: "The type '#type' of the inherited getter '#name' is not a subtype of the type '#type2' of the setter '#name2'."
script: |
//@dart=3.5
abstract class A {
num get property;
}
abstract class B implements A {
void set property(int i);
}
InvalidGetterSetterTypeFieldInherited:
parameters:
Type type: undocumented
Name name: undocumented
Type type2: undocumented
Name name2: undocumented
problemMessage: "The type '#type' of the inherited field '#name' is not a subtype of the type '#type2' of the setter '#name2'."
script: |
//@dart=3.5
abstract class A {
final num property;
A(this.property);
}
abstract class B implements A {
void set property(int i);
}
InvalidGetterSetterTypeSetterInheritedGetter:
parameters:
Type type: undocumented
Name name: undocumented
Type type2: undocumented
Name name2: undocumented
problemMessage: "The type '#type' of the getter '#name' is not a subtype of the type '#type2' of the inherited setter '#name2'."
script: |
//@dart=3.5
abstract class A {
void set property(int i);
}
abstract class B implements A {
num get property;
}
InvalidGetterSetterTypeSetterInheritedField:
parameters:
Type type: undocumented
Name name: undocumented
Type type2: undocumented
Name name2: undocumented
problemMessage: "The type '#type' of the field '#name' is not a subtype of the type '#type2' of the inherited setter '#name2'."
script: |
//@dart=3.5
abstract class A {
void set property(int i);
}
abstract class B implements A {
final num property;
B(this.property);
}
InvalidGetterSetterTypeBothInheritedField:
parameters:
Type type: undocumented
Name name: undocumented
Type type2: undocumented
Name name2: undocumented
problemMessage: "The type '#type' of the inherited field '#name' is not a subtype of the type '#type2' of the inherited setter '#name2'."
script: |
//@dart=3.5
abstract class A {
final num property;
A(this.property);
}
abstract class B {
void set property(int i);
}
abstract class C implements A, B {}
InvalidGetterSetterTypeBothInheritedGetter:
parameters:
Type type: undocumented
Name name: undocumented
Type type2: undocumented
Name name2: undocumented
problemMessage: "The type '#type' of the inherited getter '#name' is not a subtype of the type '#type2' of the inherited setter '#name2'."
script: |
//@dart=3.5
abstract class A {
num get property;
}
abstract class B {
void set property(int i);
}
abstract class C implements A, B {}
InvalidGetterSetterTypeFieldContext:
parameters:
Name name: undocumented
problemMessage: "This is the declaration of the field '#name'."
severity: CONTEXT
InvalidGetterSetterTypeGetterContext:
parameters:
Name name: undocumented
problemMessage: "This is the declaration of the getter '#name'."
severity: CONTEXT
InvalidGetterSetterTypeSetterContext:
parameters:
Name name: undocumented
problemMessage: "This is the declaration of the setter '#name'."
severity: CONTEXT
PartOfSelf:
parameters: none
problemMessage: "A file can't be a part of itself."
analyzerCode: PART_OF_NON_PART
script:
main.dart: "part 'main.dart';"
TypeParameterDuplicatedName:
parameters: none
problemMessage: "A type variable can't have the same name as another."
analyzerCode: DUPLICATE_DEFINITION
script: |
class C<A, A> {}
TypeParameterDuplicatedNameCause:
parameters:
Name name: undocumented
problemMessage: "The other type variable named '#name'."
severity: CONTEXT
TypeParameterSameNameAsEnclosing:
parameters: none
problemMessage: "A type variable can't have the same name as its enclosing declaration."
analyzerCode: CONFLICTING_TYPE_VARIABLE_AND_CLASS
script: |
class C<C> {}
AnnotationOnTypeArgument:
parameters: none
problemMessage: "Type arguments can't have annotations because they aren't declarations."
analyzerCode: ParserErrorCode.ANNOTATION_ON_TYPE_ARGUMENT
index: 111
script:
- "class A<E> {} class C { m() => new A<@Object() C>(); }"
AnnotationOnFunctionTypeTypeParameter:
parameters: none
problemMessage: "A type variable on a function type can't have annotations."
script: |
// @dart=2.13
main() { Function<@Object() T>() x; }
ExpectedEnumBody:
parameters:
Token lexeme: undocumented
problemMessage: "Expected a enum body, but got '#lexeme'."
correctionMessage: "An enum definition must have a body with at least one constant name."
analyzerCode: MISSING_ENUM_BODY
script:
- "enum E"
EnumDeclarationEmpty:
parameters: none
problemMessage: "An enum declaration can't be empty."
analyzerCode: EMPTY_ENUM_BODY
script:
- "enum E {}"
ExternalClass:
parameters: none
index: 3
problemMessage: "Classes can't be declared to be 'external'."
correctionMessage: "Try removing the keyword 'external'."
analyzerCode: ParserErrorCode.EXTERNAL_CLASS
script:
- "external class C {}"
ExternalEnum:
parameters: none
index: 5
problemMessage: "Enums can't be declared to be 'external'."
correctionMessage: "Try removing the keyword 'external'."
analyzerCode: ParserErrorCode.EXTERNAL_ENUM
script:
- "external enum E {ONE}"
ExternalMethodWithBody:
# TODO(danrubel): remove reference to `native` once support has been removed
parameters: none
index: 49
problemMessage: "An external or native method can't have a body."
analyzerCode: ParserErrorCode.EXTERNAL_METHOD_WITH_BODY
script:
- "class C {external foo() {}}"
- "class C {foo() native {}}"
- "class C {foo() native 'bar' {}}"
ExternalConstructorWithInitializer:
parameters: none
index: 106
problemMessage: "An external constructor can't have any initializers."
analyzerCode: ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER
script:
- "class C { int? x; external C() : x = 1; }"
- "class C { int? x; external C.foo() : x = 1; }"
ExternalTypedef:
parameters: none
index: 76
problemMessage: "Typedefs can't be declared to be 'external'."
correctionMessage: "Try removing the keyword 'external'."
analyzerCode: ParserErrorCode.EXTERNAL_TYPEDEF
script:
- "external typedef F();"
OperatorWithOptionalFormals:
parameters: none
problemMessage: "An operator can't have optional parameters."
script: |
class Foo {
operator ==([Object a = 0]) => true;
}
OperatorWithTypeParameters:
parameters: none
index: 120
problemMessage: "Types parameters aren't allowed when defining an operator."
correctionMessage: "Try removing the type parameters."
analyzerCode: ParserErrorCode.TYPE_PARAMETER_ON_OPERATOR
comment: |-
7.1.1 Operators: Type parameters are not syntactically supported on an
operator.
script:
- "class C { operator []<T>(T t) => null; }"
PlatformPrivateLibraryAccess:
parameters: none
problemMessage: "Can't access platform private library."
analyzerCode: IMPORT_INTERNAL_LIBRARY
script: |
import "dart:_internal";
TypedefNotFunction:
parameters: none
problemMessage: "Can't create typedef from non-function type."
analyzerCode: INVALID_GENERIC_FUNCTION_TYPE
script: |
// @dart=2.12
class Foo<X> {}
typedef Bar<X> = Foo<X>;
TypedefNotType:
parameters: none
problemMessage: "Can't create typedef from non-type."
analyzerCode: INVALID_TYPE_IN_TYPEDEF
script: |
typedef Foo = ;
exampleAllowOtherCodes: true
TypedefTypeParameterNotConstructor:
parameters: none
problemMessage: "Can't use a typedef denoting a type variable as a constructor, nor for a static member access."
script: |
typedef Foo<Bar> = Bar;
class Baz extends Foo<C> {}
class C {}
TypedefTypeParameterNotConstructorCause:
parameters: none
problemMessage: "This is the type variable ultimately denoted."
severity: CONTEXT
TypedefNullableType:
parameters: none
problemMessage: "Can't create typedef from nullable type."
script: |
// @dart=2.12
typedef F = void Function()?;
TypedefUnaliasedTypeCause:
parameters: none
problemMessage: "This is the type denoted by the type alias."
severity: CONTEXT
TypedefCause:
parameters: none
problemMessage: "The issue arises via this type alias."
severity: CONTEXT
LibraryDirectiveNotFirst:
parameters: none
index: 37
problemMessage: "The library directive must appear before all other directives."
correctionMessage: "Try moving the library directive before any other directives."
analyzerCode: ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST
script:
- "class Foo{} library l;"
- "import 'x.dart'; library l;"
- "part 'a.dart'; library l;"
exampleAllowOtherCodes: true
ImportAfterPart:
parameters: none
index: 10
problemMessage: "Import directives must precede part directives."
correctionMessage: "Try moving the import directives before the part directives."
analyzerCode: ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE
script:
- "part 'foo.dart'; import 'bar.dart';"
exampleAllowOtherCodes: true
ExportAfterPart:
parameters: none
index: 75
problemMessage: "Export directives must precede part directives."
correctionMessage: "Try moving the export directives before the part directives."
analyzerCode: ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE
exampleAllowOtherCodes: true
script:
- "part 'foo.dart'; export 'bar.dart';"
DirectiveAfterDeclaration:
parameters: none
index: 69
problemMessage: "Directives must appear before any declarations."
correctionMessage: "Try moving the directive before any declarations."
analyzerCode: ParserErrorCode.DIRECTIVE_AFTER_DECLARATION
script:
- main.dart: |
class foo { }
import 'bar.dart';
bar.dart: ""
- main.dart: |
class foo { }
export 'bar.dart';
bar.dart: ""
NonPartOfDirectiveInPart:
parameters: none
problemMessage: "The part-of directive must be the only directive in a part."
correctionMessage: "Try removing the other directives, or moving them to the library for which this is a part."
analyzerCode: NON_PART_OF_DIRECTIVE_IN_PART
script:
- "part of l; part 'f.dart';"
PartOfTwice:
parameters: none
index: 25
problemMessage: "Only one part-of directive may be declared in a file."
correctionMessage: "Try removing all but one of the part-of directives."
analyzerCode: ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES
script:
- main.dart: |
part "part.dart";
main() {}
other.dart: ""
part.dart: |
part of "other.dart";
part of "main.dart";
- main.dart: |
part of "lib.dart";
part of "lib.dart";
main() {}
lib.dart: |
part "main.dart";
- main.dart: |
part "part.dart";
part.dart: |
part of "main.dart";
part of "main.dart";
PartTwice:
parameters:
Uri uri: undocumented
problemMessage: "Can't use '#uri' as a part more than once."
analyzerCode: DUPLICATE_PART
script:
part.dart: "part of 'main.dart';"
main.dart: "part 'part.dart'; part 'part.dart';"
PartOfTwoLibraries:
parameters: none
problemMessage: "A file can't be part of more than one library."
correctionMessage: "Try moving the shared declarations into the libraries, or into a new library."
analyzerCode: PART_OF_DIFFERENT_LIBRARY
script:
main.dart: "library lib; import 'lib.dart'; part 'part.dart';"
lib.dart: "library lib; part 'part.dart';"
part.dart: "part of lib;"
PartOfTwoLibrariesContext:
parameters: none
problemMessage: "Used as a part in this library."
severity: CONTEXT
FactoryTopLevelDeclaration:
parameters: none
index: 78
problemMessage: "Top-level declarations can't be declared to be 'factory'."
correctionMessage: "Try removing the keyword 'factory'."
analyzerCode: ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION
script:
- "factory class C {}"
RedirectionInNonFactory:
parameters: none
index: 21
problemMessage: "Only factory constructor can specify '=' redirection."
correctionMessage: "Try making this a factory constructor, or remove the redirection."
analyzerCode: ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR
script:
- "class C { C() = D; }"
exampleAllowOtherCodes: true
TopLevelOperator:
parameters: none
index: 14
problemMessage: "Operators must be declared within a class."
correctionMessage: "Try removing the operator, moving it to a class, or converting it to be a function."
analyzerCode: ParserErrorCode.TOP_LEVEL_OPERATOR
script:
- "operator +(bool x, bool y) => x | y;"
- "bool operator +(bool x, bool y) => x | y;"
- "void operator +(bool x, bool y) => x | y;"
MissingFunctionParameters:
parameters: none
problemMessage: "A function declaration needs an explicit list of parameters."
correctionMessage: "Try adding a parameter list to the function declaration."
analyzerCode: MISSING_FUNCTION_PARAMETERS
script:
- "void f {}"
MissingMethodParameters:
parameters: none
problemMessage: "A method declaration needs an explicit list of parameters."
correctionMessage: "Try adding a parameter list to the method declaration."
analyzerCode: MISSING_METHOD_PARAMETERS
script:
- "class C { void m {} }"
MissingTypedefParameters:
parameters: none
problemMessage: "A typedef needs an explicit list of parameters."
correctionMessage: "Try adding a parameter list to the typedef."
analyzerCode: MISSING_TYPEDEF_PARAMETERS
script:
- "typedef void F;"
MissingPartOf:
parameters:
Uri uri: undocumented
problemMessage: "Can't use '#uri' as a part, because it has no 'part of' declaration."
analyzerCode: PART_OF_NON_PART
script:
part.dart: ""
main.dart: "part 'part.dart';"
PartOfInLibrary:
parameters:
Uri uri: undocumented
problemMessage: "Can't import '#uri', because it has a 'part of' declaration."
correctionMessage: "Try removing the 'part of' declaration, or using '#uri' as a part."
analyzerCode: IMPORT_OF_NON_LIBRARY
script:
main.dart: |
import "part.dart";
import "lib.dart";
main() {}
part.dart: |
part of "lib.dart";
lib.dart: |
part "part.dart";
PartInPart:
parameters: none
problemMessage: "A file that's a part of a library can't have parts itself."
correctionMessage: "Try moving the 'part' declaration to the containing library."
analyzerCode: NON_PART_OF_DIRECTIVE_IN_PART
script:
main.dart: |
part "part.dart";
main() {}
part.dart: |
part of "main.dart";
part "part_part.dart";
part_part.dart: |
part of "part.dart";
PartInPartLibraryContext:
parameters: none
problemMessage: "This is the containing library."
severity: CONTEXT
PartOrphan:
parameters: none
problemMessage: "This part doesn't have a containing library."
correctionMessage: "Try removing the 'part of' declaration."
script: "part of none; main() {}"
PartExport:
parameters: none
problemMessage: "Can't export this file because it contains a 'part of' declaration."
analyzerCode: EXPORT_OF_NON_LIBRARY
script:
main.dart: |
export "part.dart";
import "lib.dart";
main() {}
part.dart: |
part of "lib.dart";
lib.dart: |
part "part.dart";
PartExportContext:
parameters: none
problemMessage: "This is the file that can't be exported."
severity: CONTEXT
SupertypeIsFunction:
parameters: none
problemMessage: "Can't use a function type as supertype."
script: |
mixin M on Function() {}
DeferredPrefixDuplicated:
parameters:
Name name: undocumented
problemMessage: "Can't use the name '#name' for a deferred library, as the name is used elsewhere."
analyzerCode: SHARED_DEFERRED_PREFIX
script:
main.dart: |
import 'lib1.dart' deferred as foo;
import 'lib2.dart' as foo;
lib1.dart: ""
lib2.dart: ""
DeferredPrefixDuplicatedCause:
parameters:
Name name: undocumented
problemMessage: "'#name' is used here."
severity: CONTEXT
TypeArgumentsOnTypeVariable:
parameters:
Name name: undocumented
index: 13
problemMessage: "Can't use type arguments with type variable '#name'."
correctionMessage: "Try removing the type arguments."
analyzerCode: ParserErrorCode.TYPE_ARGUMENTS_ON_TYPE_VARIABLE
script:
- "void method<S>(S<int> a) {}"
# Use this message when a duplicated declaration is introduced. For example:
#
# class C {} // First declaration (related information points here).
# class C {} // Duplicated declaration (error here).
# main() {
# new C(); // Use of duplicated declaration.
# }
#
# We follow the convention from C that a definition is the unique element that
# provides the implementation of a name, and a declaration may not be unique
# (for example, forward declaration). Using this terminology, one could argue
# that a method that is abstract or external is a declaration, not a
# definition. Similarly, imported names are declarations, not
# definitions. Consequently, it is more convenient to use the word
# "declaration" instead of "definition" as the former implies less.
DuplicatedDeclaration:
parameters:
Name name: undocumented
problemMessage: "'#name' is already declared in this scope."
analyzerCode: DUPLICATE_DEFINITION
script: |
class C {} // First declaration (related information points here).
class C {} // Duplicated declaration (error here).
main() {
// The following line is commented out as it would lead to an extraneous
// diagnostic.
// new C(); // Use of duplicated declaration.
}
DuplicatedDeclarationCause:
parameters:
Name name: undocumented
problemMessage: "Previous declaration of '#name'."
severity: CONTEXT
DuplicatedDeclarationSyntheticCause:
parameters:
Name name: undocumented
problemMessage: "Previous declaration of '#name' is implied by this definition."
severity: CONTEXT
# Use this message when a duplicated declaration is used.
DuplicatedDeclarationUse:
parameters:
Name name: undocumented
problemMessage: "Can't use '#name' because it is declared more than once."
script:
- main.dart: |
// This test can't pass as tests must produce only one error message.
class C {} // First declaration (related information points here).
class C {} // Duplicated declaration (error here).
main() {
new C(); // Use of duplicated declaration.
}
- main.dart: |
import 'lib1.dart';
import 'lib2.dart';
main() {
new C(); // Use of duplicated declaration.
}
lib1.dart: |
class C {}
lib2.dart: |
class C {}
DuplicatedNamedArgument:
parameters:
Name name: undocumented
problemMessage: "Duplicated named argument '#name'."
analyzerCode: DUPLICATE_NAMED_ARGUMENT
script: |
foo({required int named}) {}
main() {
foo(named: 1, named: 2);
}
DuplicatedParameterName:
parameters:
Name name: undocumented
problemMessage: "Duplicated parameter name '#name'."
analyzerCode: DUPLICATE_DEFINITION
script: |
foo({required int named, required int named}) {}
DuplicatedParameterNameCause:
parameters:
Name name: undocumented
problemMessage: "Other parameter named '#name'."
severity: CONTEXT
MemberWithSameNameAsClass:
parameters: none
problemMessage: "A class member can't have the same name as the enclosing class."
correctionMessage: "Try renaming the member."
analyzerCode: ParserErrorCode.MEMBER_WITH_CLASS_NAME
index: 105
script:
- "class C { get C {} }"
- "class C { get C => 42; }"
- "class C { set C(x) {} }"
- "class C { set C(x) => 42; }"
- "class C { int? C; }"
- "class C { int? A, B, C, D, E; }"
MissingOperatorKeyword:
parameters: none
index: 31
problemMessage: "Operator declarations must be preceded by the keyword 'operator'."
correctionMessage: "Try adding the keyword 'operator'."
analyzerCode: ParserErrorCode.MISSING_KEYWORD_OPERATOR
script:
- "class C { +(x) {} }"
InvalidOperator:
parameters:
Token lexeme: undocumented
index: 39
problemMessage: "The string '#lexeme' isn't a user-definable operator."
analyzerCode: ParserErrorCode.INVALID_OPERATOR
comment: |-
Parameters:
0: the operator that is invalid
script:
- "class C { void operator %=(x) {} }"
NotBinaryOperator:
parameters:
Token lexeme: undocumented
problemMessage: "'#lexeme' isn't a binary operator."
script: |
class C { operator~() { return null; } }
main() {
C c = new C();
print(c ~ 2);
}
OperatorParameterMismatch0:
parameters:
Name name: undocumented
problemMessage: "Operator '#name' shouldn't have any parameters."
script: |
class Foo {
operator ~(a) => true;
}
OperatorParameterMismatch1:
parameters:
Name name: undocumented
problemMessage: "Operator '#name' should have exactly one parameter."
analyzerCode: WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR
script: |
class Foo {
operator ==() => true;
}
exampleAllowOtherCodes: true
OperatorParameterMismatch2:
parameters:
Name name: undocumented
problemMessage: "Operator '#name' should have exactly two parameters."
analyzerCode: WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR
script: |
class Foo {
operator []=(a, b, c) => true;
}
OperatorMinusParameterMismatch:
parameters:
Name name: undocumented
problemMessage: "Operator '#name' should have zero or one parameter."
correctionMessage: >-
With zero parameters, it has the syntactic form '-a', formally known as 'unary-'.
With one parameter, it has the syntactic form 'a - b', formally known as '-'.
analyzerCode: WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS
script: |
class Foo {
operator -(a, b) => true;
}
SupertypeIsIllegal:
parameters:
Name name: undocumented
problemMessage: "The type '#name' can't be used as supertype."
analyzerCode: EXTENDS_NON_CLASS
script: |
class C extends dynamic {}
SupertypeIsIllegalAliased:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The type '#name' which is an alias of '#type' can't be used as supertype."
analyzerCode: EXTENDS_NON_CLASS
script: |
typedef F = void Function();
class C extends F {}
SupertypeIsNullableAliased:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The type '#name' which is an alias of '#type' can't be used as supertype because it is nullable."
analyzerCode: EXTENDS_NON_CLASS
script: |
class A {}
typedef B = A?;
class C extends B {}
SupertypeIsTypeParameter:
parameters:
Name name: undocumented
problemMessage: "The type variable '#name' can't be used as supertype."
analyzerCode: EXTENDS_NON_CLASS
script: |
class C<T> extends T {}
SuperExtensionTypeIsIllegal:
parameters:
Name name: undocumented
problemMessage: "The type '#name' can't be implemented by an extension type."
script: |
extension type E(dynamic it) implements dynamic {}
SuperExtensionTypeIsIllegalAliased:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The type '#name' which is an alias of '#type' can't be implemented by an extension type."
script: |
typedef F = void Function();
extension type E(F it) implements F {}
SuperExtensionTypeIsNullableAliased:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The type '#name' which is an alias of '#type' can't be implemented by an extension type because it is nullable."
script: |
class A {}
typedef B = A?;
extension type E(B it) implements B {}
SuperExtensionTypeIsTypeParameter:
parameters:
Name name: undocumented
problemMessage: "The type variable '#name' can't be implemented by an extension type."
script: |
extension type E<T>(T it) implements T {}
PartOfLibraryNameMismatch:
parameters:
Uri uri: undocumented
Name name: undocumented
Name name2: undocumented
problemMessage: "Using '#uri' as part of '#name' but its 'part of' declaration says '#name2'."
analyzerCode: PART_OF_DIFFERENT_LIBRARY
script:
main.dart: |
library foo;
part 'lib.dart';
lib.dart: |
part of bar;
PartOfUseUri:
parameters:
Uri uri: undocumented
Uri uri2: undocumented
Name name: undocumented
problemMessage: "Using '#uri' as part of '#uri2' but its 'part of' declaration says '#name'."
correctionMessage: "Try changing the 'part of' declaration to use a relative file name."
analyzerCode: PART_OF_UNNAMED_LIBRARY
script:
main.dart: |
part 'lib.dart';
lib.dart: |
part of foo;
PartOfUriMismatch:
parameters:
Uri uri: undocumented
Uri uri2: undocumented
Uri uri3: undocumented
problemMessage: "Using '#uri' as part of '#uri2' but its 'part of' declaration says '#uri3'."
analyzerCode: PART_OF_DIFFERENT_LIBRARY
script:
main.dart: |
part 'lib.dart';
lib.dart: |
part of 'lib2.dart';
lib2.dart: ""
MissingMain:
parameters: none
problemMessage: "No 'main' method found."
correctionMessage: "Try adding a method named 'main' to your program."
MissingInput:
parameters: none
problemMessage: "No input file provided to the compiler."
InputFileNotFound:
parameters:
Uri uri: undocumented
problemMessage: "Input file not found: #uri."
SdkRootNotFound:
parameters:
Uri uri: undocumented
problemMessage: "SDK root directory not found: #uri."
SdkSummaryNotFound:
parameters:
Uri uri: undocumented
problemMessage: "SDK summary not found: #uri."
SdkSpecificationNotFound:
parameters:
Uri uri: undocumented
problemMessage: "SDK libraries specification not found: #uri."
correctionMessage: "Normally, the specification is a file named 'libraries.json' in the Dart SDK install location."
InvalidSuperInInitializer:
parameters: none
index: 47
problemMessage: "Can only use 'super' in an initializer for calling the superclass constructor (e.g. 'super()' or 'super.namedConstructor()')"
analyzerCode: ParserErrorCode.INVALID_SUPER_IN_INITIALIZER
InvalidThisInInitializer:
parameters: none
index: 65
problemMessage: "Can only use 'this' in an initializer for field initialization (e.g. 'this.x = something') and constructor redirection (e.g. 'this()' or 'this.namedConstructor())"
analyzerCode: ParserErrorCode.INVALID_THIS_IN_INITIALIZER
ThisAccessInFieldInitializer:
parameters:
Name name: undocumented
problemMessage: "Can't access 'this' in a field initializer to read '#name'."
script: |
class Foo {
int a = 2;
int b = a + 42;
}
ThisOrSuperAccessInFieldInitializer:
parameters:
String string: undocumented
problemMessage: "Can't access '#string' in a field initializer."
analyzerCode: THIS_ACCESS_FROM_INITIALIZER
script: |
class C {
var x = this;
}
ThisAsIdentifier:
parameters: none
problemMessage: "Expected identifier, but got 'this'."
analyzerCode: INVALID_REFERENCE_TO_THIS
script: |
class C {}
void foo() {
C.this();
}
# TODO(johnniwinther): Confusing message, it should probably mention that `super` is not available.
SuperAsIdentifier:
parameters: none
problemMessage: "Expected identifier, but got 'super'."
analyzerCode: SUPER_AS_EXPRESSION
script: |
class C {}
void foo() {
C.super();
}
InvalidAugmentSuper:
parameters: none
problemMessage: "'augment super' is only allowed in member augmentations."
SuperAsExpression:
parameters: none
problemMessage: "Can't use 'super' as an expression."
correctionMessage: "To delegate a constructor to a super constructor, put the super call as an initializer."
analyzerCode: SUPER_AS_EXPRESSION
script: |
abstract class A {}
class B extends A {
B(): super()?.foo() {}
}
exampleAllowOtherCodes: true
SwitchExpressionNotAssignableCause:
parameters: none
problemMessage: "The switch expression is here."
severity: CONTEXT
SwitchExpressionNotSubtype:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "Type '#type' of the case expression is not a subtype of type '#type2' of this switch expression."
script:
- |
// @dart=2.19
void f() {
switch (42) {
case "foo": break;
}
}
SwitchHasCaseAfterDefault:
parameters: none
index: 16
problemMessage: "The default case should be the last case in a switch statement."
correctionMessage: "Try moving the default case after the other case clauses."
analyzerCode: ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE
script:
- "class C { foo(int a) {switch (a) {default: return 0; case 1: return 1;}} }"
SwitchHasMultipleDefaults:
parameters: none
index: 15
problemMessage: "The 'default' case can only be declared once."
correctionMessage: "Try removing all but one default case."
analyzerCode: ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES
script:
- "class C { foo(int a) {switch (a) {default: return 0; default: return 1;}} }"
SwitchCaseFallThrough:
parameters: none
problemMessage: "Switch case may fall through to the next case."
analyzerCode: CASE_BLOCK_NOT_TERMINATED
script: |
// @dart=2.19
method(e) {
switch (e) {
case 0: print(0);
case 1: print(1);
}
}
FieldAlreadyInitializedAtDeclaration:
parameters:
Name name: undocumented
problemMessage: "'#name' is a final instance variable that was initialized at the declaration."
analyzerCode: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION
script:
- "class C { final int x = 2; C(): this.x = 3 {} }"
FieldAlreadyInitializedAtDeclarationCause:
parameters:
Name name: undocumented
problemMessage: "'#name' was initialized here."
severity: CONTEXT
ConstructorInitializeSameInstanceVariableSeveralTimes:
parameters:
Name name: undocumented
problemMessage: "'#name' was already initialized by this constructor."
analyzerCode: FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS
script:
- "class C { final int x; C(): this.x = 1, this.x = 2 {} }"
- "class C { int x; C(): this.x = 1, this.x = 2 {} }"
TypeVariableInStaticContext:
parameters: none
problemMessage: "Type variables can't be used in static members."
analyzerCode: TYPE_PARAMETER_REFERENCED_BY_STATIC
declaration:
- |
class C<T> {
static List<T> staticMethod() {}
}
- |
class C<T> {
static T staticMethod() {}
}
- |
class C<T> {
static staticMethod(List<T> argument) {}
}
- |
class C<T> {
static staticMethod(T argument) {}
}
- |
class C<T> {
static staticMethod() {
List<T>? t = null;
return t;
}
}
- |
class C<T> {
static staticMethod() {
T? t = null;
return t;
}
}
TypeVariableInConstantContext:
parameters: none
problemMessage: "Type variables can't be used as constants."
analyzerCode: TYPE_PARAMETER_IN_CONST_EXPRESSION
declaration:
- |
class C<T> {
instanceMethod() {
return const <Object>[T];
}
}
- |
class C<T> {
instanceMethod() {
return const <T>[];
}
}
- |
class C<T> {
instanceMethod() {
return const <List<T>>[];
}
}
SuperclassHasNoMember:
parameters:
Name name: undocumented
problemMessage: "Superclass has no member named '#name'."
analyzerCode: UNDEFINED_SUPER_GETTER
SuperclassHasNoGetter:
parameters:
Name name: undocumented
problemMessage: "Superclass has no getter named '#name'."
analyzerCode: UNDEFINED_SUPER_GETTER
script: |
class Super {}
class Class extends Super {
method() {
super.missingSuperGetter;
}
}
SuperclassHasNoSetter:
parameters:
Name name: undocumented
problemMessage: "Superclass has no setter named '#name'."
analyzerCode: UNDEFINED_SUPER_SETTER
script: |
class Super {}
class Class extends Super {
method() {
super.missingSuperSetter = 42;
}
}
SuperclassHasNoMethod:
parameters:
Name name: undocumented
problemMessage: "Superclass has no method named '#name'."
analyzerCode: UNDEFINED_SUPER_METHOD
script: |
class Super {}
class Class extends Super {
method() {
super.missingSuperMethod();
}
}
SuperclassHasNoConstructor:
parameters:
Name name: undocumented
problemMessage: "Superclass has no constructor named '#name'."
analyzerCode:
- UNDEFINED_CONSTRUCTOR_IN_INITIALIZER
- UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT
script:
- |
class Super {
Super._();
}
class Sub extends Super {
Sub() : super();
}
- |
class Super {
Super._();
}
class Sub extends Super {
Sub.foo() : super.foo();
}
SuperclassHasNoDefaultConstructor:
parameters:
Name name: undocumented
problemMessage: "The superclass, '#name', has no unnamed constructor that takes no arguments."
analyzerCode: NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT
script: |
class Foo {
Foo(int x);
}
class Bar extends Foo { }
ConstConstructorNonFinalField:
parameters: none
problemMessage: "Constructor is marked 'const' so all fields must be final."
analyzerCode: CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD
script: |
class Foo {
int i;
const Foo(this.i);
}
ConstConstructorNonFinalFieldCause:
parameters: none
problemMessage: "Field isn't final, but constructor is 'const'."
severity: CONTEXT
ConstConstructorLateFinalFieldError:
parameters: none
problemMessage: "Can't have a late final field in a class with a const constructor."
script: |
class Foo {
late final int i = 42;
const Foo();
}
ConstConstructorLateFinalFieldCause:
parameters: none
problemMessage: "This constructor is const."
severity: CONTEXT
ConstConstructorRedirectionToNonConst:
parameters: none
problemMessage: "A constant constructor can't call a non-constant constructor."
script:
- >-
class A {
const A.foo() : this.bar();
A.bar() {}
}
ConstConstructorWithNonConstSuper:
parameters: none
problemMessage: "A constant constructor can't call a non-constant super constructor."
analyzerCode: CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER
script:
- >-
class A {
A.bar() {}
}
class B extends A {
const B.foo() : super.bar();
}
ExpressionNotMetadata:
parameters: none
problemMessage: "This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor."
script: |
@foo
void foo() {}
ExpectedAnInitializer:
parameters: none
index: 36
problemMessage: "Expected an initializer."
analyzerCode: ParserErrorCode.MISSING_INITIALIZER
script:
- "class C { C() : {} }"
MissingAssignmentInInitializer:
parameters: none
index: 34
problemMessage: "Expected an assignment after the field name."
correctionMessage: "To initialize a field, use the syntax 'name = value'."
analyzerCode: ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER
script:
- "class C { C() : x(3) {} }"
exampleAllowOtherCodes: true
RedirectingConstructorWithBody:
parameters: none
index: 22
problemMessage: "Redirecting constructors can't have a body."
correctionMessage: "Try removing the body, or not making this a redirecting constructor."
analyzerCode: ParserErrorCode.REDIRECTING_CONSTRUCTOR_WITH_BODY
script:
- "class C { C() : this.x() {} }"
exampleAllowOtherCodes: true
CannotAssignToParenthesizedExpression:
parameters: none
problemMessage: "Can't assign to a parenthesized expression."
analyzerCode: ASSIGNMENT_TO_PARENTHESIZED_EXPRESSION
script: |
int i = 42;
int test2() {
return (i) ++ (i);
}
exampleAllowOtherCodes: true
NotAnLvalue:
parameters: none
problemMessage: "Can't assign to this."
analyzerCode: NOT_AN_LVALUE
script: |
class Foo {
void bar() {
--toString();
}
}
CannotAssignToSuper:
parameters: none
problemMessage: "Can't assign to super."
analyzerCode: NOT_AN_LVALUE
IllegalAssignmentToNonAssignable:
parameters: none
index: 45
problemMessage: "Illegal assignment to non-assignable expression."
analyzerCode: ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
script:
- "main(){ f()++; }"
MissingAssignableSelector:
parameters: none
index: 35
problemMessage: "Missing selector such as '.identifier' or '[0]'."
correctionMessage: "Try adding a selector."
analyzerCode: ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR
script:
- "main(){ ++f(); }"
CannotReadSdkSpecification:
parameters:
String string: undocumented
problemMessage: "Unable to read the 'libraries.json' specification file:\n #string."
CantInferPackagesFromManyInputs:
parameters: none
problemMessage: "Can't infer a packages file when compiling multiple inputs."
correctionMessage: "Try specifying the file explicitly with the --packages option."
CantInferPackagesFromPackageUri:
parameters: none
problemMessage: "Can't infer a packages file from an input 'package:*' URI."
correctionMessage: "Try specifying the file explicitly with the --packages option."
PackageNotFound:
parameters:
Name name: undocumented
Uri uri: undocumented
problemMessage: "Couldn't resolve the package '#name' in '#uri'."
script: |
import 'package:foo/foo.dart';
exampleAllowOtherCodes: true
InvalidPackageUri:
parameters:
Uri uri: undocumented
String string: undocumented
problemMessage: "Invalid package URI '#uri':\n #string."
script: |
import 'package:foo';
exampleAllowOtherCodes: true
CouldNotParseUri:
parameters:
String string: undocumented
String string2: undocumented
problemMessage: "Couldn't parse URI '#string':\n #string2."
script: |
import ' dart:async';
exampleAllowOtherCodes: true
ExpectedUri:
parameters: none
problemMessage: "Expected a URI."
script: |
import ' dart:async';
exampleAllowOtherCodes: true
InterpolationInUri:
parameters: none
problemMessage: "Can't use string interpolation in a URI."
analyzerCode: INVALID_LITERAL_IN_CONFIGURATION
script: |
import 'package:/foo/$bar.dart';
exampleAllowOtherCodes: true
IntegerLiteralIsOutOfRange:
parameters:
String string: undocumented
problemMessage: "The integer literal #string can't be represented in 64 bits."
correctionMessage: "Try using the BigInt class if you need an integer larger than 9,223,372,036,854,775,807 or less than -9,223,372,036,854,775,808."
analyzerCode: INTEGER_LITERAL_OUT_OF_RANGE
script: |
void foo() {
int i = 9223372036854775808;
}
ColonInPlaceOfIn:
parameters: none
index: 54
problemMessage: "For-in loops use 'in' rather than a colon."
correctionMessage: "Try replacing the colon with the keyword 'in'."
analyzerCode: ParserErrorCode.COLON_IN_PLACE_OF_IN
script: |
void foo() {
for(var x : []) {}
}
BinaryOperatorWrittenOut:
parameters:
String string: undocumented
String string2: undocumented
index: 112
problemMessage: "Binary operator '#string' is written as '#string2' instead of the written out word."
correctionMessage: "Try replacing '#string' with '#string2'."
analyzerCode: ParserErrorCode.BINARY_OPERATOR_WRITTEN_OUT
script: |
int foo(int x, int y) => x xor y;
ExternalFactoryRedirection:
parameters: none
index: 85
problemMessage: "A redirecting factory can't be external."
correctionMessage: "Try removing the 'external' modifier."
analyzerCode: ParserErrorCode.EXTERNAL_FACTORY_REDIRECTION
script: |
class Foo {
Foo._(int i);
external factory Foo.x(int i) = Foo._;
}
ArgumentTypeNotAssignable:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The argument type '#type' can't be assigned to the parameter type '#type2'."
analyzerCode: ARGUMENT_TYPE_NOT_ASSIGNABLE
script: |
method(int i) {}
main() {
method(1.5);
}
InvalidAssignmentError:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "A value of type '#type' can't be assigned to a variable of type '#type2'."
analyzerCode: INVALID_ASSIGNMENT
script: |
main() {
int i;
i = 1.5;
}
PatchClassTypeParametersMismatch:
parameters: none
problemMessage: "A patch class must have the same number of type variables as its origin class."
PatchClassOrigin:
parameters: none
problemMessage: "This is the origin class."
severity: CONTEXT
PatchExtensionTypeParametersMismatch:
parameters: none
problemMessage: "A patch extension must have the same number of type variables as its origin extension."
PatchExtensionOrigin:
parameters: none
problemMessage: "This is the origin extension."
severity: CONTEXT
PatchDeclarationOrigin:
parameters: none
problemMessage: "This is the origin declaration."
severity: CONTEXT
PatchInjectionFailed:
parameters:
Name name: undocumented
Uri uri: undocumented
problemMessage: "Can't inject public '#name' into '#uri'."
correctionMessage: "Make '#name' private, or make sure injected library has \"dart\" scheme and is private (e.g. \"dart:_internal\")."
InvalidCastFunctionExpr:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The function expression type '#type' isn't of expected type '#type2'."
correctionMessage: "Change the type of the function expression or the context in which it is used."
analyzerCode: INVALID_CAST_FUNCTION_EXPR
InvalidCastLiteralList:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The list literal type '#type' isn't of expected type '#type2'."
correctionMessage: "Change the type of the list literal or the context in which it is used."
analyzerCode: INVALID_CAST_LITERAL_LIST
InvalidCastLiteralMap:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The map literal type '#type' isn't of expected type '#type2'."
correctionMessage: "Change the type of the map literal or the context in which it is used."
analyzerCode: INVALID_CAST_LITERAL_MAP
InvalidCastLiteralSet:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The set literal type '#type' isn't of expected type '#type2'."
correctionMessage: "Change the type of the set literal or the context in which it is used."
analyzerCode: INVALID_CAST_LITERAL_SET
InvalidCastLocalFunction:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The local function has type '#type' that isn't of expected type '#type2'."
correctionMessage: "Change the type of the function or the context in which it is used."
analyzerCode: INVALID_CAST_FUNCTION
InvalidCastNewExpr:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The constructor returns type '#type' that isn't of expected type '#type2'."
correctionMessage: "Change the type of the object being constructed or the context in which it is used."
analyzerCode: INVALID_CAST_NEW_EXPR
InvalidCastStaticMethod:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The static method has type '#type' that isn't of expected type '#type2'."
correctionMessage: "Change the type of the method or the context in which it is used."
analyzerCode: INVALID_CAST_METHOD
InvalidCastTopLevelFunction:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The top level function has type '#type' that isn't of expected type '#type2'."
correctionMessage: "Change the type of the function or the context in which it is used."
analyzerCode: INVALID_CAST_FUNCTION
InvalidUseOfNullAwareAccess:
parameters: none
problemMessage: "Cannot use '?.' here."
correctionMessage: "Try using '.'."
analyzerCode: INVALID_USE_OF_NULL_AWARE_ACCESS
script: |
class Super {
Super.named();
}
class Class extends Super {
Class() : super?.named();
}
exampleAllowOtherCodes: true
UndefinedGetter:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The getter '#name' isn't defined for the type '#type'."
correctionMessage: "Try correcting the name to the name of an existing getter, or defining a getter or field named '#name'."
analyzerCode: UNDEFINED_GETTER
script: |
class C {}
test(C c) {
print(c.foo);
}
UndefinedSetter:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The setter '#name' isn't defined for the type '#type'."
correctionMessage: "Try correcting the name to the name of an existing setter, or defining a setter or field named '#name'."
analyzerCode: UNDEFINED_SETTER
script: |
class C {}
test(C c) {
c.foo = 0;
}
UndefinedMethod:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The method '#name' isn't defined for the type '#type'."
correctionMessage: "Try correcting the name to the name of an existing method, or defining a method named '#name'."
analyzerCode: UNDEFINED_METHOD
script: |
class C {}
test(C c) {
c.foo();
}
UndefinedOperator:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The operator '#name' isn't defined for the type '#type'."
correctionMessage: "Try correcting the operator to an existing operator, or defining a '#name' operator."
analyzerCode: UNDEFINED_METHOD
script: |
class C {}
test(C c) {
c + 0;
}
AmbiguousExtensionMethod:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The method '#name' is defined in multiple extensions for '#type' and neither is more specific."
correctionMessage: "Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope."
script: |
class C {}
extension A on C { method() {} }
extension B on C { method() {} }
main() {
C c = new C();
c.method();
}
AmbiguousExtensionProperty:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The property '#name' is defined in multiple extensions for '#type' and neither is more specific."
correctionMessage: "Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope."
script: |
class C {}
extension A on C { get property => null; }
extension B on C { set property(_) {} }
main() {
C c = new C();
c.property;
}
AmbiguousExtensionOperator:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The operator '#name' is defined in multiple extensions for '#type' and neither is more specific."
correctionMessage: "Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope."
script: |
class C {}
extension A on C { operator +(int i) {} }
extension B on C { operator +(int i) {} }
main() {
C c = new C();
c + 0;
}
AmbiguousExtensionCause:
parameters: none
problemMessage: "This is one of the extension members."
severity: CONTEXT
SourceOutlineSummary:
parameters:
int count: undocumented
int count2: undocumented
num num1: undocumented
num num2: undocumented
num num3: undocumented
problemMessage: |
Built outlines for #count compilation units (#count2 bytes) in #num1%.3ms, that is,
#num2%12.3 bytes/ms, and
#num3%12.3 ms/compilation unit.
SourceBodySummary:
parameters:
int count: undocumented
int count2: undocumented
num num1: undocumented
num num2: undocumented
num num3: undocumented
problemMessage: |
Built bodies for #count compilation units (#count2 bytes) in #num1%.3ms, that is,
#num2%12.3 bytes/ms, and
#num3%12.3 ms/compilation unit.
DillOutlineSummary:
parameters:
int count: undocumented
int count2: undocumented
num num1: undocumented
num num2: undocumented
num num3: undocumented
problemMessage: |
Indexed #count libraries (#count2 bytes) in #num1%.3ms, that is,
#num2%12.3 bytes/ms, and
#num3%12.3 ms/libraries.
CantInferTypesDueToNoCombinedSignature:
parameters:
Name name: undocumented
problemMessage: "Can't infer types for '#name' as the overridden members don't have a combined signature."
correctionMessage: "Try adding explicit types."
analyzerCode: COMPILE_TIME_ERROR.NO_COMBINED_SUPER_SIGNATURE
script: |
class A {
void method(int a, String b) {}
}
class B {
void method(String a, int b) {}
}
class C implements A, B {
void method(a, b) {}
}
CantInferTypeDueToNoCombinedSignature:
parameters:
Name name: undocumented
problemMessage: "Can't infer a type for '#name' as the overridden members don't have a combined signature."
correctionMessage: "Try adding an explicit type."
analyzerCode: COMPILE_TIME_ERROR.NO_COMBINED_SUPER_SIGNATURE
script: |
class A {
void method(int a) {}
}
class B {
void method(String a) {}
}
class C implements A, B {
void method(a) {}
}
CantInferReturnTypeDueToNoCombinedSignature:
parameters:
Name name: undocumented
problemMessage: "Can't infer a return type for '#name' as the overridden members don't have a combined signature."
correctionMessage: "Try adding an explicit type."
analyzerCode: COMPILE_TIME_ERROR.NO_COMBINED_SUPER_SIGNATURE
script: |
abstract class A {
int get getter;
}
abstract class B {
String get getter;
}
abstract class C implements A, B {
get getter;
}
CantInferTypeDueToCircularity:
parameters:
String string: undocumented
problemMessage: "Can't infer the type of '#string': circularity found during type inference."
correctionMessage: "Specify the type explicitly."
analyzerCode: RECURSIVE_COMPILE_TIME_CONSTANT
script: |
enum CyclicReference {
e1(e2),
e2(e1);
final CyclicReference other;
const CyclicReference(this.other);
}
exampleAllowOtherCodes: true
AmbiguousSupertypes:
parameters:
Name name: undocumented
Type type: undocumented
Type type2: undocumented
problemMessage: "'#name' can't implement both '#type' and '#type2'"
analyzerCode: AMBIGUOUS_SUPERTYPES
script: |
class A<T> {}
mixin class B<T> implements A<T> {}
class C<T> implements A<T> {}
class D implements B<String>, C<int> {}
MixinInferenceNoMatchingClass:
parameters:
Name name: undocumented
Name name2: undocumented
Type type: undocumented
problemMessage: "Type parameters couldn't be inferred for the mixin '#name' because '#name2' does not implement the mixin's supertype constraint '#type'."
analyzerCode: MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION
script: |
abstract class A<T> {}
mixin M<T> on A<T> {}
class C extends Object with M {}
exampleAllowOtherCodes: true
ImplicitCallOfNonMethod:
parameters:
Type type: undocumented
problemMessage: "Cannot invoke an instance of '#type' because it declares 'call' to be something other than a method."
correctionMessage: "Try changing 'call' to a method or explicitly invoke 'call'."
analyzerCode: IMPLICIT_CALL_OF_NON_METHOD
script: |
class Class { void Function() get call => () {}; }
method(Class c) => c();
ImplicitSuperCallOfNonMethod:
parameters: none
problemMessage: "Cannot invoke `super` because it declares 'call' to be something other than a method."
correctionMessage: "Try changing 'call' to a method or explicitly invoke 'call'."
analyzerCode: IMPLICIT_CALL_OF_NON_METHOD
script: |
class Super { void Function() get call => () {}; }
class Class extends Super { void method() => super(); }
ExpectedOneExpression:
parameters: none
problemMessage: "Expected one expression, but found additional input."
ForInLoopNotAssignable:
parameters: none
problemMessage: "Can't assign to this, so it can't be used in a for-in loop."
statement: "for (1 in []) {}"
exampleAllowOtherCodes: true
ForInLoopExactlyOneVariable:
parameters: none
problemMessage: "A for-in loop can't have more than one loop variable."
statement: "for (var x, y in []) {}"
exampleAllowOtherCodes: true
ForInLoopWithConstVariable:
parameters: none
problemMessage: "A for-in loop-variable can't be 'const'."
correctionMessage: "Try removing the 'const' modifier."
analyzerCode: FOR_IN_WITH_CONST_VARIABLE
script: |
void foo() {
for(const i in [42]) {}
}
ForInLoopElementTypeNotAssignable:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "A value of type '#type' can't be assigned to a variable of type '#type2'."
correctionMessage: "Try changing the type of the variable."
analyzerCode: FOR_IN_OF_INVALID_ELEMENT_TYPE
script: |
method() {
List<String> list = [];
for (int i in list) {}
}
ForInLoopTypeNotIterable:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The type '#type' used in the 'for' loop must implement '#type2'."
analyzerCode: FOR_IN_OF_INVALID_TYPE
script: |
method() {
String list = '';
for (int i in list) {}
}
InitializingFormalTypeMismatch:
parameters:
Name name: undocumented
Type type: undocumented
Type type2: undocumented
problemMessage: "The type of parameter '#name', '#type' is not a subtype of the corresponding field's type, '#type2'."
correctionMessage: "Try changing the type of parameter '#name' to a subtype of '#type2'."
analyzerCode: INVALID_PARAMETER_DECLARATION
script: |
class C {
int x;
C(num this.x);
}
InitializingFormalTypeMismatchField:
parameters: none
problemMessage: "The field that corresponds to the parameter."
severity: CONTEXT
InitializeFromDillNotSelfContained:
parameters:
String string: undocumented
Uri uri: undocumented
problemMessage: |
Tried to initialize from a previous compilation (#string), but the file was not self-contained. This might be a bug.
The Dart team would greatly appreciate it if you would take a moment to report this problem at http://dartbug.com/new.
If you are comfortable with it, it would improve the chances of fixing any bug if you included the file #uri in your error report, but be aware that this file includes your source code.
Either way, you should probably delete the file so it doesn't use unnecessary disk space.
severity: WARNING
frontendInternal: true
external: test/incremental_load_from_invalid_dill_test.dart
InitializeFromDillNotSelfContainedNoDump:
parameters:
String string: undocumented
problemMessage: |
Tried to initialize from a previous compilation (#string), but the file was not self-contained. This might be a bug.
The Dart team would greatly appreciate it if you would take a moment to report this problem at http://dartbug.com/new.
severity: WARNING
frontendInternal: true
external: test/incremental_load_from_invalid_dill_test.dart
InitializeFromDillUnknownProblem:
parameters:
String string: undocumented
String string2: undocumented
String string3: undocumented
Uri uri: undocumented
problemMessage: |
Tried to initialize from a previous compilation (#string), but couldn't.
Error message was '#string2'.
Stacktrace included '#string3'.
This might be a bug.
The Dart team would greatly appreciate it if you would take a moment to report this problem at http://dartbug.com/new.
If you are comfortable with it, it would improve the chances of fixing any bug if you included the file #uri in your error report, but be aware that this file includes your source code.
Either way, you should probably delete the file so it doesn't use unnecessary disk space.
severity: WARNING
frontendInternal: true
external: test/incremental_load_from_invalid_dill_test.dart
InitializeFromDillUnknownProblemNoDump:
parameters:
String string: undocumented
String string2: undocumented
String string3: undocumented
problemMessage: |
Tried to initialize from a previous compilation (#string), but couldn't.
Error message was '#string2'.
Stacktrace included '#string3'.
This might be a bug.
The Dart team would greatly appreciate it if you would take a moment to report this problem at http://dartbug.com/new.
severity: WARNING
frontendInternal: true
external: test/incremental_load_from_invalid_dill_test.dart
WebLiteralCannotBeRepresentedExactly:
parameters:
String string: undocumented
String string2: undocumented
problemMessage: "The integer literal #string can't be represented exactly in JavaScript."
correctionMessage: "Try changing the literal to something that can be represented in JavaScript. In JavaScript #string2 is the nearest value that can be represented exactly."
BoundIssueViaRawTypeWithNonSimpleBounds:
parameters:
Name name: undocumented
problemMessage: "Generic type '#name' can't be used without type arguments in a type variable bound."
correctionMessage: "Try providing type arguments to '#name' here."
analyzerCode: NOT_INSTANTIATED_BOUND
script: |
class Hest<X extends Hest<X>> {}
class Fisk<Y extends Hest> {}
NonSimpleBoundViaVariable:
parameters:
Name name: undocumented
problemMessage: "Bound of this variable references variable '#name' from the same declaration."
severity: CONTEXT
BoundIssueViaLoopNonSimplicity:
parameters:
Name name: undocumented
problemMessage: "Generic type '#name' can't be used without type arguments in the bounds of its own type variables."
correctionMessage: "Try providing type arguments to '#name' here."
analyzerCode: NOT_INSTANTIATED_BOUND
script: |
class Hest<X extends Hest> {}
BoundIssueViaCycleNonSimplicity:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "Generic type '#name' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through '#name2'."
correctionMessage: "Try providing type arguments to '#name2' here or to some other raw types in the bounds along the reference chain."
analyzerCode: NOT_INSTANTIATED_BOUND
script: |
class Hest<X extends Fisk> {}
class Fisk<Y extends Hest> {}
NonSimpleBoundViaReference:
parameters:
Name name: undocumented
problemMessage: "Bound of this variable references raw type '#name'."
severity: CONTEXT
CycleInTypeParameters:
parameters:
Name name: undocumented
String string: undocumented
problemMessage: "Type '#name' is a bound of itself via '#string'."
correctionMessage: "Try breaking the cycle by removing at least one of the 'extends' clauses in the cycle."
analyzerCode: TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND
script:
- "foo<A extends B, B extends A>() {}"
DirectCycleInTypeParameters:
parameters:
Name name: undocumented
problemMessage: "Type '#name' can't use itself as a bound."
correctionMessage: "Try breaking the cycle by removing at least one of the 'extends' clauses in the cycle."
analyzerCode: TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND
script:
- "foo<A extends A>() {}"
CantUsePrefixAsExpression:
parameters: none
problemMessage: "A prefix can't be used as an expression."
analyzerCode: PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
script: |
import "dart:core" as prefix;
main() {
for (prefix in []) {}
}
CantUsePrefixWithNullAware:
parameters: none
problemMessage: "A prefix can't be used with null-aware operators."
correctionMessage: "Try replacing '?.' with '.'"
analyzerCode: PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
script: |
import "dart:core" as prefix;
main() {
prefix?.Object;
}
CantUseControlFlowOrSpreadAsConstant:
parameters:
Token lexeme: undocumented
problemMessage: "'#lexeme' is not supported in constant expressions."
analyzerCode: NOT_CONSTANT_EXPRESSION
script: |
test() {
const List<int> list1 = const [for (var i = 1; i < 4; i++) i];
}
exampleAllowOtherCodes: true
CantUseDeferredPrefixAsConstant:
parameters:
Token lexeme: undocumented
problemMessage: >
'#lexeme' can't be used in a constant expression because it's marked as
'deferred' which means it isn't available until loaded.
correctionMessage: >
Try moving the constant from the deferred library, or removing 'deferred'
from the import.
analyzerCode: CONST_DEFERRED_CLASS
script: |
import "dart:convert" deferred as prefix;
main() {
const prefix.JsonCodec();
}
CyclicRedirectingFactoryConstructors:
parameters:
Name name: undocumented
problemMessage: "Cyclic definition of factory '#name'."
analyzerCode: RECURSIVE_FACTORY_REDIRECT
script: |
class Foo {
factory Foo.foo() = Foo.bar;
factory Foo.bar() = Foo.foo;
}
main() { var foo = new Foo.foo(); }
exampleAllowMultipleReports: true
GenericFunctionTypeInBound:
parameters: none
problemMessage: "Type variables can't have generic function types in their bounds."
analyzerCode: GENERIC_FUNCTION_TYPE_CANNOT_BE_BOUND
script: |
// @dart=2.13
class Hest<X extends Y Function<Y>(Y)> {}
VoidExpression:
parameters: none
problemMessage: "This expression has type 'void' and can't be used."
analyzerCode: USE_OF_VOID_RESULT
statement: |
{
void x;
int y = x;
}
ReturnFromVoidFunction:
parameters: none
problemMessage: "Can't return a value from a void function."
analyzerCode: RETURN_OF_INVALID_TYPE
declaration: "void foo() { return 1; }"
ReturnWithoutExpressionSync:
parameters: none
problemMessage: "A value must be explicitly returned from a non-void function."
script: |
import "dart:async";
FutureOr<Object?> foo() { return; }
ReturnWithoutExpressionAsync:
parameters: none
problemMessage: "A value must be explicitly returned from a non-void async function."
declaration: "Future<int> foo() async { return; }"
InvalidReturn:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "A value of type '#type' can't be returned from a function with return type '#type2'."
declaration: "int foo() { return true; }"
InvalidReturnAsync:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "A value of type '#type' can't be returned from an async function with return type '#type2'."
declaration: "Future<int> foo() async { return true; }"
ImplicitReturnNull:
parameters:
Type type: undocumented
problemMessage: "A non-null value must be returned since the return type '#type' doesn't allow null."
script: |
String method() {}
RethrowNotCatch:
parameters: none
problemMessage: "'rethrow' can only be used in catch clauses."
analyzerCode: RETHROW_OUTSIDE_CATCH
script: |
void foo() {
try {
rethrow;
} catch (e) {}
}
InvokeNonFunction:
parameters:
Name name: undocumented
problemMessage: "'#name' isn't a function or method and can't be invoked."
analyzerCode: INVOCATION_OF_NON_FUNCTION
script: |
abstract class Foo {
int get f;
}
method(Foo foo) => foo.f();
ConstInstanceField:
parameters: none
problemMessage: "Only static fields can be declared as const."
correctionMessage: "Try using 'final' instead of 'const', or adding the keyword 'static'."
analyzerCode: CONST_INSTANCE_FIELD
script:
- "class C { const field = 0; }"
DefaultValueInRedirectingFactoryConstructor:
parameters:
Name name: undocumented
problemMessage: "Can't have a default value here because any default values of '#name' would be used instead."
correctionMessage: "Try removing the default value."
analyzerCode: DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR
script:
- >-
class A {
factory A.f({int x = 42}) = A.g;
A.g({int x = 40}) {}
}
UntranslatableUri:
parameters:
Uri uri: undocumented
problemMessage: "Not found: '#uri'"
analyzerCode: URI_DOES_NOT_EXIST
exampleAllowOtherCodes: true # PackageNotFound will precede this message.
script: |
import "package:expect/non_existing_file";
UnavailableDartLibrary:
parameters:
Uri uri: undocumented
problemMessage: "Dart library '#uri' is not available on this platform."
analyzerCode: URI_DOES_NOT_EXIST
script: |
import "dart:non_existing_library";
ImportChainContext:
parameters:
Uri uri: undocumented
String string: undocumented
String string2: undocumented
problemMessage: |
The unavailable library '#uri' is imported through these packages:
#string
Detailed import paths for (some of) the these imports:
#string2
severity: CONTEXT
ImportChainContextSimple:
parameters:
Uri uri: undocumented
String string: undocumented
problemMessage: |
The unavailable library '#uri' is imported through these paths:
#string
severity: CONTEXT
CantReadFile:
parameters:
Uri uri: undocumented
String string: undocumented
problemMessage: "Error when reading '#uri': #string"
analyzerCode: URI_DOES_NOT_EXIST
external: test/packages_format_error_test.dart
script: |
import "non_existing_file.dart";
ExceptionReadingFile:
parameters:
Uri uri: undocumented
String string: undocumented
problemMessage: "Exception when reading '#uri': #string"
PackagesFileFormat:
parameters:
String string: undocumented
problemMessage: "Problem in packages configuration file: #string"
external: test/packages_format_error_test.dart
IncompatibleRedirecteeFunctionType:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The constructor function type '#type' isn't a subtype of '#type2'."
analyzerCode: REDIRECT_TO_INVALID_TYPE
script:
- >-
class A {
factory A() = B;
}
class B {
B();
}
- >-
class A {
factory A.one(int x) = A.zero;
A.zero() {}
}
- >-
class A {
factory A.i(int x) = A.s;
A.s(String x) { }
}
- >-
class A {
factory A.f({int? x}) = A.g;
A.g({int? y}) { }
}
- >-
class A {
factory A.f(int x) = A.g;
A.g(int x, int y) {}
}
RedirectingFactoryIncompatibleTypeArgument:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The type '#type' doesn't extend '#type2'."
correctionMessage: "Try using a different type as argument."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script:
- >-
class A<T extends int> {
factory A() = B<T, int>;
}
class B<T extends int, S extends String> implements A<T> {}
SyntheticToken:
parameters: none
problemMessage: "This couldn't be parsed."
frontendInternal: true
IncorrectTypeArgument:
parameters:
Type type: undocumented
Type type2: undocumented
Name name: undocumented
Name name2: undocumented
problemMessage: "Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2'."
correctionMessage: "Try changing type arguments so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: |
class C<T extends num> {}
main() { new C<String>(); }
IncorrectTypeArgumentQualified:
parameters:
Type type: undocumented
Type type2: undocumented
Name name: undocumented
Type type3: undocumented
Name name2: undocumented
problemMessage: "Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3.#name2'."
correctionMessage: "Try changing type arguments so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: |
class C<T> { foo<U extends num>() {} }
main() { new C<String>().foo<String>(); }
IncorrectTypeArgumentInferred:
parameters:
Type type: undocumented
Type type2: undocumented
Name name: undocumented
Name name2: undocumented
problemMessage: "Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2'."
correctionMessage: "Try specifying type arguments explicitly so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: |
foo<T extends List<S>, S extends num>(T t) {}
main() { foo(<String>[""]); }
IncorrectTypeArgumentQualifiedInferred:
parameters:
Type type: undocumented
Type type2: undocumented
Name name: undocumented
Type type3: undocumented
Name name2: undocumented
problemMessage: "Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3.#name2'."
correctionMessage: "Try specifying type arguments explicitly so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: |
class A { foo<T extends List<S>, S extends num>(T t) {} }
main() { new A().foo(<String>[""]); }
IncorrectTypeArgumentInstantiation:
parameters:
Type type: undocumented
Type type2: undocumented
Name name: undocumented
Type type3: undocumented
problemMessage: "Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3'."
correctionMessage: "Try changing type arguments so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: |
X bounded<X extends num>(X x) => x;
main() {
bounded<String>;
}
IncorrectTypeArgumentInstantiationInferred:
parameters:
Type type: undocumented
Type type2: undocumented
Name name: undocumented
Type type3: undocumented
problemMessage: "Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3'."
correctionMessage: "Try specifying type arguments explicitly so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: |
X bounded<X extends List<Y>, Y extends num>(X x) => x;
main() {
List<String> Function(List<String>) c = bounded;
}
IncorrectTypeArgumentVariable:
parameters: none
problemMessage: "This is the type variable whose bound isn't conformed to."
severity: CONTEXT
SuperBoundedHint:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "If you want '#type' to be a super-bounded type, note that the inverted type '#type2' must then satisfy its bounds, which it does not."
severity: CONTEXT
MixinApplicationIncompatibleSupertype:
parameters:
Type type: undocumented
Type type2: undocumented
Type type3: undocumented
problemMessage: "'#type' doesn't implement '#type2' so it can't be used with '#type3'."
analyzerCode: MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
script: |-
class I {}
mixin M on I {}
class C = Object with M;
GenericFunctionTypeUsedAsActualTypeArgument:
parameters: none
problemMessage: "A generic function type can't be used as a type argument."
correctionMessage: "Try using a non-generic function type."
analyzerCode: GENERIC_FUNCTION_CANNOT_BE_TYPE_ARGUMENT
script:
- |
// @dart=2.13
typedef F = Class<T> Function<T>(T);
class Class<T> {}
main() {
Class<F> class1;
}
- |
// @dart=2.13
typedef F = Class<T> Function<T>(T);
class Class<T> {}
main() {
Class<F>();
}
GenericFunctionTypeInferredAsActualTypeArgument:
parameters:
Type type: undocumented
problemMessage: "Generic function type '#type' inferred as a type argument."
correctionMessage: "Try providing a non-generic function type explicitly."
analyzerCode: GENERIC_FUNCTION_CANNOT_BE_TYPE_ARGUMENT
script: |
// @dart=2.13
foo<X>(X x) => null;
bar<Y>(Y y) => null;
main() { foo(bar); }
GenericFunctionTypeAsTypeArgumentThroughTypedef:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "Generic function type '#type' used as a type argument through typedef '#type2'."
correctionMessage: "Try providing a non-generic function type explicitly."
analyzerCode: GENERIC_FUNCTION_CANNOT_BE_TYPE_ARGUMENT
script:
main.dart: |
// @dart=2.12
import 'lib.dart';
test(T3 t3a) {}
lib.dart: |
typedef T3 = List<void Function<T>(T)>;
# These two message templates are used for constructing supplemental text
# about the origins of raw interface types in error messages containing types.
TypeOrigin:
parameters:
Name name: undocumented
Uri uri: undocumented
problemMessage: "'#name' is from '#uri'."
frontendInternal: true
external: test/type_labeler_test.dart
TypeOriginWithFileUri:
parameters:
Name name: undocumented
Uri uri: undocumented
Uri uri2: undocumented
problemMessage: "'#name' is from '#uri' ('#uri2')."
frontendInternal: true
external: test/type_labeler_test.dart
ObjectExtends:
parameters: none
problemMessage: "The class 'Object' can't have a superclass."
frontendInternal: true
external: test/object_supertype_test.dart
ObjectImplements:
parameters: none
problemMessage: "The class 'Object' can't implement anything."
frontendInternal: true
external: test/object_supertype_test.dart
ObjectMixesIn:
parameters: none
problemMessage: "The class 'Object' can't use mixins."
frontendInternal: true
external: test/object_supertype_test.dart
InstanceAndSynthesizedStaticConflict:
parameters:
Name name: undocumented
problemMessage: "This instance member conflicts with the synthesized static member called '#name'."
analyzerCode: CONFLICTING_STATIC_AND_INSTANCE
script: |
enum E {
e1, e2;
void set values(List<E> val) {}
}
FfiAbiSpecificIntegerInvalid:
# Used by dart:ffi
parameters: none
problemMessage: "Classes extending 'AbiSpecificInteger' must have exactly one const constructor, no other members, and no type arguments."
external: test/ffi_test.dart
FfiAbiSpecificIntegerMappingInvalid:
# Used by dart:ffi
parameters: none
problemMessage: "Classes extending 'AbiSpecificInteger' must have exactly one 'AbiSpecificIntegerMapping' annotation specifying the mapping from ABI to a NativeType integer with a fixed size."
external: test/ffi_test.dart
FfiAddressPosition:
# Used by dart:ffi
parameters: none
problemMessage: "The '.address' expression can only be used as argument to a leaf native external call."
external: test/ffi_test.dart
FfiAddressReceiver:
# Used by dart:ffi
parameters: none
problemMessage: "The receiver of '.address' must be a concrete 'TypedData', a concrete 'TypedData' '[]', an 'Array', an 'Array' '[]', a Struct field, or a Union field."
correctionMessage: "Change the receiver of '.address' to one of the allowed kinds."
external: test/ffi_test.dart
FfiCreateOfStructOrUnion:
# Used by dart:ffi
parameters: none
problemMessage: "Subclasses of 'Struct' and 'Union' are backed by native memory, and can't be instantiated by a generative constructor. Try allocating it via allocation, or load from a 'Pointer'."
external: test/ffi_test.dart
FfiTypeMismatch:
# Used by dart:ffi
parameters:
Type type: undocumented
Type type2: undocumented
Type type3: undocumented
problemMessage: "Expected type '#type' to be '#type2', which is the Dart type corresponding to '#type3'."
external: test/ffi_test.dart
FfiEmptyStruct:
# Used by dart:ffi
parameters:
String string: undocumented
Name name: undocumented
problemMessage: "#string '#name' is empty. Empty structs and unions are undefined behavior."
external: test/ffi_test.dart
FfiTypeInvalid:
# Used by dart:ffi
parameters:
Type type: undocumented
problemMessage: "Expected type '#type' to be a valid and instantiated subtype of 'NativeType'."
external: test/ffi_test.dart
FfiFieldNull:
# Used by dart:ffi
parameters:
Name name: undocumented
problemMessage: "Field '#name' cannot be nullable or have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`."
external: test/ffi_test.dart
FfiFieldAnnotation:
# Used by dart:ffi
parameters:
Name name: undocumented
problemMessage: "Field '#name' requires exactly one annotation to declare its native type, which cannot be Void. dart:ffi Structs and Unions cannot have regular Dart fields."
external: test/ffi_test.dart
FfiFieldNoAnnotation:
# Used by dart:ffi
parameters:
Name name: undocumented
problemMessage: "Field '#name' requires no annotation to declare its native type, it is a Pointer which is represented by the same type in Dart and native code."
external: test/ffi_test.dart
FfiFieldCyclic:
# Used by dart:ffi
parameters:
String string: undocumented
Name name: undocumented
Names names: undocumented
problemMessage: |
#string '#name' contains itself. Cycle elements:
#names
external: test/ffi_test.dart
FfiNotStatic:
# Used by dart:ffi
parameters:
Name name: undocumented
problemMessage: "#name expects a static function as parameter. dart:ffi only supports calling static Dart functions from native code. Closures and tear-offs are not supported because they can capture context."
external: test/ffi_test.dart
FfiFieldInitializer:
# Used by dart:ffi
parameters:
Name name: undocumented
problemMessage: "Field '#name' is a dart:ffi Pointer to a struct field and therefore cannot be initialized before constructor execution."
correctionMessage: "Mark the field as external to avoid having to initialize it."
external: test/ffi_test.dart
FfiExtendsOrImplementsSealedClass:
# Used by dart:ffi
parameters:
Name name: undocumented
problemMessage: "Class '#name' cannot be extended or implemented."
external: test/ffi_test.dart
FfiPackedAnnotation:
# Used by dart:ffi
parameters:
Name name: undocumented
problemMessage: "Struct '#name' must have at most one 'Packed' annotation."
external: test/ffi_test.dart
FfiPackedAnnotationAlignment:
# Used by dart:ffi
parameters: none
problemMessage: "Only packing to 1, 2, 4, 8, and 16 bytes is supported."
external: test/ffi_test.dart
FfiSizeAnnotation:
# Used by dart:ffi
parameters:
Name name: undocumented
problemMessage: "Field '#name' must have exactly one 'Array' annotation."
external: test/ffi_test.dart
FfiSizeAnnotationDimensions:
# Used by dart:ffi
parameters:
Name name: undocumented
problemMessage: "Field '#name' must have an 'Array' annotation that matches the dimensions."
external: test/ffi_test.dart
FfiVariableLengthArrayNotLast:
# Used by dart:ffi
parameters: none
problemMessage: "Variable length 'Array's must only occur as the last field of Structs."
correctionMessage: "Try adjusting the arguments in the 'Array' annotation."
external: test/ffi_test.dart
FfiStructGeneric:
# Used by dart:ffi
parameters:
String string: undocumented
Name name: undocumented
problemMessage: "#string '#name' should not be generic."
external: test/ffi_test.dart
FfiCompoundImplementsFinalizable:
# Used by dart:ffi
parameters:
String string: undocumented
Name name: undocumented
problemMessage: "#string '#name' can't implement Finalizable."
correctionMessage: "Try removing the implements clause from '#name'."
external: test/ffi_test.dart
FfiDartTypeMismatch:
# Used by dart:ffi
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "Expected '#type' to be a subtype of '#type2'."
external: test/ffi_test.dart
FfiDeeplyImmutableClassesMustBeFinalOrSealed:
# Used by dart:ffi
parameters: none
problemMessage: 'Deeply immutable classes must be final or sealed.'
correctionMessage: 'Try marking this class as final or sealed.'
external: test/ffi_test.dart
FfiDeeplyImmutableFieldsMustBeDeeplyImmutable:
# Used by dart:ffi
parameters: none
problemMessage: "Deeply immutable classes must only have deeply immutable instance fields. Deeply immutable types include 'int', 'double', 'bool', 'String', 'Pointer', 'Float32x4', 'Float64x2', 'Int32x4', and classes annotated with `@pragma('vm:deeply-immutable')`."
correctionMessage: 'Try changing the type of this field to a deeply immutable type or mark the type of this field as deeply immutable.'
external: test/ffi_test.dart
FfiDeeplyImmutableFieldsModifiers:
# Used by dart:ffi
parameters: none
problemMessage: 'Deeply immutable classes must only have final non-late instance fields.'
correctionMessage: "Add the 'final' modifier to this field, and remove 'late' modifier from this field."
external: test/ffi_test.dart
FfiDeeplyImmutableSubtypesMustBeDeeplyImmutable:
# Used by dart:ffi
parameters: none
problemMessage: 'Subtypes of deeply immutable classes must be deeply immutable.'
correctionMessage: "Try marking this class deeply immutable by adding `@pragma('vm:deeply-immutable')`."
external: test/ffi_test.dart
FfiDeeplyImmutableSupertypeMustBeDeeplyImmutable:
# Used by dart:ffi
parameters: none
problemMessage: 'The super type of deeply immutable classes must be deeply immutable.'
correctionMessage: "Try marking the super class deeply immutable by adding `@pragma('vm:deeply-immutable')`."
external: test/ffi_test.dart
FfiDefaultAssetDuplicate:
# Used by dart:ffi
parameters: none
problemMessage: "There may be at most one @DefaultAsset annotation on a library."
external: test/ffi_test.dart
analyzerCode: FFI_NATIVE_INVALID_DUPLICATE_DEFAULT_ASSET
FfiExpectedExceptionalReturn:
# Used by dart:ffi
parameters:
Type type: undocumented
problemMessage: "Expected an exceptional return value for a native callback returning '#type'."
external: test/ffi_test.dart
FfiExpectedNoExceptionalReturn:
# Used by dart:ffi
parameters:
Type type: undocumented
problemMessage: "Exceptional return value cannot be provided for a native callback returning '#type'."
external: test/ffi_test.dart
FfiExpectedConstant:
# Used by dart:ffi
parameters: none
problemMessage: "Exceptional return value must be a constant."
external: test/ffi_test.dart
FfiExceptionalReturnNull:
# Used by dart:ffi
parameters: none
problemMessage: "Exceptional return value must not be null."
external: test/ffi_test.dart
FfiNativeCallableListenerReturnVoid:
# Used by dart:ffi
parameters:
Type type: undocumented
problemMessage: "The return type of the function passed to NativeCallable.listener must be void rather than '#type'."
external: test/ffi_test.dart
FfiExpectedConstantArg:
# Used by dart:ffi
parameters:
Name name: undocumented
problemMessage: "Argument '#name' must be a constant."
external: test/ffi_test.dart
FfiLeafCallMustNotTakeHandle:
# Used by dart:ffi
parameters: none
problemMessage: "FFI leaf call must not have Handle argument types."
external: test/ffi_test.dart
FfiLeafCallMustNotReturnHandle:
# Used by dart:ffi
parameters: none
problemMessage: "FFI leaf call must not have Handle return type."
external: test/ffi_test.dart
FfiNativeUnexpectedNumberOfParametersWithReceiver:
# Used by dart:ffi
parameters:
int count: undocumented
int count2: undocumented
problemMessage: "Unexpected number of Native annotation parameters. Expected #count but has #count2. Native instance method annotation must have receiver as first argument."
external: test/ffi_test.dart
FfiNativeUnexpectedNumberOfParameters:
# Used by dart:ffi
parameters:
int count: undocumented
int count2: undocumented
problemMessage: "Unexpected number of Native annotation parameters. Expected #count but has #count2."
external: test/ffi_test.dart
FfiNativeOnlyNativeFieldWrapperClassCanBePointer:
# Used by dart:ffi
parameters: none
problemMessage: "Only classes extending NativeFieldWrapperClass1 can be passed as Pointer."
external: test/ffi_test.dart
FfiNativeMustBeExternal:
# Used by dart:ffi
parameters: none
problemMessage: "Native functions and fields must be marked external."
external: test/ffi_test.dart
FfiNativeDuplicateAnnotations:
# Used by dart:ffi
parameters: none
problemMessage: "Native functions and fields must not have more than @Native annotation."
external: test/ffi_test.dart
analyzerCode: FFI_NATIVE_INVALID_MULTIPLE_ANNOTATIONS
FfiNativeFieldMustBeStatic:
# Used by dart:ffi
parameters: none
problemMessage: "Native fields must be static."
analyzerCode: NATIVE_FIELD_NOT_STATIC
external: test/ffi_test.dart
FfiNativeFieldMissingType:
# Used by dart:ffi
parameters: none
problemMessage: "The native type of this field could not be inferred and must be specified in the annotation."
analyzerCode: NATIVE_FIELD_MISSING_TYPE
external: test/ffi_test.dart
FfiNativeFieldType:
# Used by dart:ffi
parameters: none
problemMessage: "Unsupported type for native fields. Native fields only support pointers, compounds and numeric types."
analyzerCode: NATIVE_FIELD_INVALID_TYPE
external: test/ffi_test.dart
FfiNativeFunctionMissingType:
# Used by dart:ffi
parameters: none
problemMessage: "The native type of this function couldn't be inferred so it must be specified in the annotation."
analyzerCode: NATIVE_FUNCTION_MISSING_TYPE
external: test/ffi_test.dart
FfiAddressOfMustBeNative:
# Used by dart:ffi
parameters: none
problemMessage: "Argument to 'Native.addressOf' must be annotated with @Native."
analyzerCode: ARGUMENT_MUST_BE_NATIVE
external: test/ffi_test.dart
SpreadTypeMismatch:
parameters:
Type type: undocumented
problemMessage: "Unexpected type '#type' of a spread. Expected 'dynamic' or an Iterable."
script:
- |
main() {
int a = 42;
var b = [...a];
}
- |
main() {
int Function() a = () => 42;
var b = [...a];
}
CantHaveNamedParameters:
# Used by dart:ffi
parameters:
Name name: undocumented
problemMessage: "'#name' can't be declared with named parameters."
external: test/ffi_test.dart
CantHaveOptionalParameters:
# Used by dart:ffi
parameters:
Name name: undocumented
problemMessage: "'#name' can't be declared with optional parameters."
external: test/ffi_test.dart
SpreadElementTypeMismatch:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "Can't assign spread elements of type '#type' to collection elements of type '#type2'."
analyzerCode: LIST_ELEMENT_TYPE_NOT_ASSIGNABLE
script: |
main() {
List<String> a = <String>["foo"];
List<int> b = <int>[...a];
}
SpreadMapEntryTypeMismatch:
parameters:
Type type: undocumented
problemMessage: "Unexpected type '#type' of a map spread entry. Expected 'dynamic' or a Map."
script:
- |
main() {
int a = 42;
var b = <dynamic, dynamic>{...a};
}
- |
main() {
int Function() a = () => 42;
var b = <dynamic, dynamic>{...a};
}
SpreadMapEntryElementKeyTypeMismatch:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "Can't assign spread entry keys of type '#type' to map entry keys of type '#type2'."
analyzerCode: MAP_KEY_TYPE_NOT_ASSIGNABLE
script: |
main() {
Map<String, int> a = <String, int>{"foo": 42};
Map<int, int> b = <int, int>{...a};
}
SpreadMapEntryElementValueTypeMismatch:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "Can't assign spread entry values of type '#type' to map entry values of type '#type2'."
analyzerCode: MAP_VALUE_TYPE_NOT_ASSIGNABLE
script: |
main() {
Map<String, int> a = <String, int>{"foo": 42};
Map<String, String> b = <String, String>{...a};
}
CantDisambiguateNotEnoughInformation:
parameters: none
problemMessage: "Not enough type information to disambiguate between literal set and literal map."
correctionMessage: "Try providing type arguments for the literal explicitly to disambiguate it."
script: |
foo(dynamic spread) {
var a = {...spread};
}
CantDisambiguateAmbiguousInformation:
parameters: none
problemMessage: "Both Iterable and Map spread elements encountered in ambiguous literal."
script: |
foo(Iterable<int> iterableSpread, Map<int, int> mapSpread) {
var c = {...iterableSpread, ...mapSpread};
}
SpreadElement:
parameters: none
problemMessage: "Iterable spread."
severity: CONTEXT
SpreadMapElement:
parameters: none
problemMessage: "Map spread."
severity: CONTEXT
NonNullAwareSpreadIsNull:
parameters:
Type type: undocumented
problemMessage: "Can't spread a value with static type '#type'."
script: |
main() {
<int>[...null];
}
NegativeVariableDimension:
# Used by dart:ffi
parameters: none
problemMessage: "The variable dimension of a variable-length array must be non-negative."
external: test/ffi_test.dart
NonPositiveArrayDimensions:
# Used by dart:ffi
parameters: none
problemMessage: "Array dimensions must be positive numbers."
external: test/ffi_test.dart
InvalidTypeParameterInSupertype:
parameters:
Name name: undocumented
String string2: undocumented
Name name2: undocumented
problemMessage: "Can't use implicitly 'out' variable '#name' in an '#string2' position in supertype '#name2'."
script: |
class A<X> {}
class B<Y> extends A<Function(Y)> {}
InvalidTypeParameterInSupertypeWithVariance:
parameters:
String string: undocumented
Name name: undocumented
String string2: undocumented
Name name2: undocumented
problemMessage: "Can't use '#string' type variable '#name' in an '#string2' position in supertype '#name2'."
script: |
class A<out X> {}
class B<out Y> extends A<Function(Y)> {}
exampleAllowOtherCodes: true
InvalidTypeParameterVariancePosition:
parameters:
String string: undocumented
Name name: undocumented
String string2: undocumented
problemMessage: "Can't use '#string' type variable '#name' in an '#string2' position."
script: |
class A<out T> {
void method(T x) {}
exampleAllowOtherCodes: true
InvalidTypeParameterVariancePositionInReturnType:
parameters:
String string: undocumented
Name name: undocumented
String string2: undocumented
problemMessage: "Can't use '#string' type variable '#name' in an '#string2' position in the return type."
script: |
class A<in T> {
T method() {
return null;
}
}
exampleAllowOtherCodes: true
CombinedMemberSignatureFailed:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "Class '#name' inherits multiple members named '#name2' with incompatible signatures."
correctionMessage: "Try adding a declaration of '#name2' to '#name'."
analyzerCode: INCONSISTENT_INHERITANCE
script:
- |
abstract class I1 {
foo(x);
}
abstract class I2 {
foo();
}
abstract class C implements I2, I1 {}
ExtensionTypeCombinedMemberSignatureFailed:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "Extension type '#name' inherits multiple members named '#name2' with incompatible signatures."
correctionMessage: "Try adding a declaration of '#name2' to '#name'."
analyzerCode: INCONSISTENT_INHERITANCE
script:
- |
abstract class I1 {
void foo(int? x);
}
abstract class I2 {
void foo();
}
abstract class I3 implements I1, I2 {
void foo([int? x]);
}
extension type C(I3 i) implements I2, I1 {}
LanguageVersionTooHighExplicit:
parameters:
int count: undocumented
int count2: undocumented
int count3: undocumented
int count4: undocumented
problemMessage: "The specified language version #count.#count2 is too high. The highest supported language version is #count3.#count4."
script: |
// @dart=100.200
exampleAllowMultipleReports: true
LanguageVersionTooHighPackage:
parameters:
int count: undocumented
int count2: undocumented
Name name: undocumented
int count3: undocumented
int count4: undocumented
problemMessage: "The language version #count.#count2 specified for the package '#name' is too high. The highest supported language version is #count3.#count4."
script:
.dart_tool/package_config.json: |
{
"configVersion": 2,
"packages": [
{
"name": "foo",
"rootUri": "../foo/",
"languageVersion": "42.84"
}
]
}
main.dart: |
import 'package:foo/lib.dart';
foo/lib.dart: ""
LanguageVersionTooLowExplicit:
parameters:
int count: undocumented
int count2: undocumented
int count3: undocumented
int count4: undocumented
problemMessage: "The specified language version #count.#count2 is too low. The lowest supported language version is #count3.#count4."
script: |
// @dart=2.9
exampleAllowMultipleReports: true
LanguageVersionTooLowPackage:
parameters:
int count: undocumented
int count2: undocumented
Name name: undocumented
int count3: undocumented
int count4: undocumented
problemMessage: "The language version #count.#count2 specified for the package '#name' is too low. The lowest supported language version is #count3.#count4."
script:
.dart_tool/package_config.json: |
{
"configVersion": 2,
"packages": [
{
"name": "foo",
"rootUri": "../foo/",
"languageVersion": "2.11"
}
]
}
main.dart: |
import 'package:foo/lib.dart';
foo/lib.dart: ""
LanguageVersionInvalidInDotPackages:
parameters: none
problemMessage: "The language version is not specified correctly in the packages file."
exampleAllowOtherCodes: true
script:
main.dart: "import 'package:foo/foo.dart';"
lib/foo.dart: "// blah blah blah"
.dart_tool/package_config.json: |
{
"configVersion": 2,
"packages": [
{
"name": "foo",
"rootUri": "../lib/",
"languageVersion": "arglebargle"
}
]
}
LanguageVersionMismatchInPart:
parameters: none
problemMessage: "The language version override has to be the same in the library and its part(s)."
script:
main.dart: |
// @dart = 2.13
part 'part.dart';
part.dart: |
// @dart = 2.12
part of 'main.dart';
LanguageVersionMismatchInPatch:
parameters: none
problemMessage: "The language version override has to be the same in the library and its patch(es)."
LanguageVersionLibraryContext:
parameters: none
problemMessage: "This is language version annotation in the library."
severity: CONTEXT
LanguageVersionPartContext:
parameters: none
problemMessage: "This is language version annotation in the part."
severity: CONTEXT
LanguageVersionPatchContext:
parameters: none
problemMessage: "This is language version annotation in the patch."
severity: CONTEXT
ExplicitExtensionArgumentMismatch:
parameters: none
problemMessage: "Explicit extension application requires exactly 1 positional argument."
script: |
extension Extension on int {
method(a) {}
}
main() {
int i = 42;
Extension(i, i).method(null);
}
ExplicitExtensionTypeArgumentMismatch:
parameters:
Name name: undocumented
int count: undocumented
problemMessage: "Explicit extension application of extension '#name' takes '#count' type argument(s)."
script: |
extension Extension on int {
method(a) {}
}
main() {
int i = 42;
Extension<int>(i).method(null);
}
ExplicitExtensionAsExpression:
parameters: none
problemMessage: "Explicit extension application cannot be used as an expression."
script: |
extension Extension on int {}
errors(int i) {
Extension(i);
}
ExplicitExtensionAsLvalue:
parameters: none
problemMessage: "Explicit extension application cannot be a target for assignment."
DeferredExtensionImport:
parameters:
Name name: undocumented
problemMessage: "Extension '#name' cannot be imported through a deferred import."
correctionMessage: "Try adding the `hide #name` to the import."
script:
main.dart: "import 'lib.dart' deferred as prefix;"
lib.dart: "extension Extension on void {}"
MultipleVarianceModifiers:
parameters: none
index: 97
problemMessage: "Each type parameter can have at most one variance modifier."
correctionMessage: "Use at most one of the 'in', 'out', or 'inout' modifiers."
analyzerCode: ParserErrorCode.MULTIPLE_VARIANCE_MODIFIERS
experiments: variance
script: |
class C<in out X> {}
VariableCouldBeNullDueToWrite:
parameters:
Name name: undocumented
String string: undocumented
problemMessage: "Variable '#name' could not be promoted due to an assignment."
correctionMessage: "Try null checking the variable after the assignment. See #string"
script: |
void foo(int? i, int? j) {
if (i == null) return;
i = j;
i.isEven;
}
includeErrorContext: true
exampleAllowOtherCodes: true
FieldNotPromotedBecauseNotEnabled:
parameters:
Name name: undocumented
String string: undocumented
problemMessage: "'#name' couldn't be promoted because field promotion is only available in Dart 3.2 and above."
correctionMessage: "See #string"
script: |
// @dart=3.1
class C {
final int? _i;
C(this._i);
}
test(C c) {
if (c._i != null) {
c._i.isEven;
}
}
includeErrorContext: true
exampleAllowOtherCodes: true
FieldNotPromotedBecauseNotField:
parameters:
Name name: undocumented
String string: undocumented
problemMessage: "'#name' refers to a getter so it couldn't be promoted."
correctionMessage: "See #string"
script: |
class C {
int? get _i => 0;
}
test(C c) {
if (c._i != null) {
c._i.isEven;
}
}
includeErrorContext: true
exampleAllowOtherCodes: true
FieldNotPromotedBecauseNotPrivate:
parameters:
Name name: undocumented
String string: undocumented
problemMessage: "'#name' refers to a public property so it couldn't be promoted."
correctionMessage: "See #string"
script: |
class C {
final int? i;
C(this.i);
}
test(C c) {
if (c.i != null) {
c.i.isEven;
}
}
includeErrorContext: true
exampleAllowOtherCodes: true
FieldNotPromotedBecauseExternal:
parameters:
Name name: undocumented
String string: undocumented
problemMessage: "'#name' refers to an external field so it couldn't be promoted."
correctionMessage: "See #string"
script: |
class C {
external final int? _i;
}
test(C c) {
if (c._i != null) {
c._i.isEven;
}
}
includeErrorContext: true
exampleAllowOtherCodes: true
FieldNotPromotedBecauseNotFinal:
parameters:
Name name: undocumented
String string: undocumented
problemMessage: "'#name' refers to a non-final field so it couldn't be promoted."
correctionMessage: "See #string"
script: |
class C {
int? _i;
C(this._i);
}
test(C c) {
if (c._i != null) {
c._i.isEven;
}
}
includeErrorContext: true
exampleAllowOtherCodes: true
FieldNotPromotedBecauseConflictingGetter:
parameters:
Name name: undocumented
Name name2: undocumented
String string: undocumented
problemMessage: "'#name' couldn't be promoted because there is a conflicting getter in class '#name2'."
correctionMessage: "See #string"
script: |
class C {
final int? _i;
C(this._i);
}
class D {
int? get _i => 0;
}
test(C c) {
if (c._i != null) {
c._i.isEven;
}
}
includeErrorContext: true
exampleAllowOtherCodes: true
FieldNotPromotedBecauseConflictingField:
parameters:
Name name: undocumented
Name name2: undocumented
String string: undocumented
problemMessage: "'#name' couldn't be promoted because there is a conflicting non-promotable field in class '#name2'."
correctionMessage: "See #string"
script: |
class C {
final int? _i;
C(this._i);
}
class D {
int? _i;
D(this._i);
}
test(C c) {
if (c._i != null) {
c._i.isEven;
}
}
includeErrorContext: true
exampleAllowOtherCodes: true
FieldNotPromotedBecauseConflictingNsmForwarder:
parameters:
Name name: undocumented
Name name2: undocumented
String string: undocumented
problemMessage: "'#name' couldn't be promoted because there is a conflicting noSuchMethod forwarder in class '#name2'."
correctionMessage: "See #string"
script: |
class C {
final int? _i;
C(this._i);
}
class D implements C {
noSuchMethod(invocation) => 0;
}
test(C c) {
if (c._i != null) {
c._i.isEven;
}
}
includeErrorContext: true
exampleAllowOtherCodes: true
ThisNotPromoted:
parameters:
String string: undocumented
problemMessage: "'this' can't be promoted."
correctionMessage: "See #string"
script: |
extension on int? {
bool extension_explicit_this() {
if (this == null) return false;
return this.isEven;
}
}
includeErrorContext: true
exampleAllowOtherCodes: true
NullablePropertyAccessError:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "Property '#name' cannot be accessed on '#type' because it is potentially null."
correctionMessage: "Try accessing using ?. instead."
script: |
bool foo(int? i) => i.isEven;
NullableMethodCallError:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "Method '#name' cannot be called on '#type' because it is potentially null."
correctionMessage: "Try calling using ?. instead."
script: |
void foo(int? i) => i.abs();
NullableExpressionCallError:
parameters:
Type type: undocumented
problemMessage: "Can't use an expression of type '#type' as a function because it's potentially null."
correctionMessage: "Try calling using ?.call instead."
script: |
void foo(Function()? f) => f();
NullableOperatorCallError:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "Operator '#name' cannot be called on '#type' because it is potentially null."
script: |
void foo(int? i) => i - 1;
NullableTearoffError:
parameters:
Name name: undocumented
problemMessage: "Can't tear off method '#name' from a potentially null value."
script: |
class Foo {
void call() {}
}
void x(Foo? f) {
Function y = f;
}
NullableSpreadError:
parameters: none
problemMessage: "An expression whose value can be 'null' must be null-checked before it can be dereferenced."
script: |
void foo(List<int>? bar) => [...bar];
ThrowingNotAssignableToObjectError:
parameters:
Type type: undocumented
problemMessage: "Can't throw a value of '#type' since it is neither dynamic nor non-nullable."
script: |
void foo(String? s) => throw s;
RequiredNamedParameterHasDefaultValueError:
parameters:
Name name: undocumented
problemMessage: "Named parameter '#name' is required and can't have a default value."
script: |
error() {
void g({required int b = 42}) {}
}
ValueForRequiredParameterNotProvidedError:
parameters:
Name name: undocumented
problemMessage: "Required named parameter '#name' must be provided."
script: |
void foo({required int i}) {}
void bar() { foo(); }
OptionalNonNullableWithoutInitializerError:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The parameter '#name' can't have a value of 'null' because of its type '#type', but the implicit default value is 'null'."
correctionMessage: "Try adding either an explicit non-'null' default value or the 'required' modifier."
analyzerCode: MISSING_DEFAULT_VALUE_FOR_PARAMETER
script:
- method1({int a}) {}
- method2([int a]) {}
FieldNonNullableWithoutInitializerError:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "Field '#name' should be initialized because its type '#type' doesn't allow null."
script: |
class Foo {
int x;
}
FieldNonNullableNotInitializedByConstructorError:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "This constructor should initialize field '#name' because its type '#type' doesn't allow null."
script: |
class Foo {
int x;
Foo(this.x);
Foo.other();
}
ExperimentOptOutExplicit:
parameters:
String string: undocumented
String string2: undocumented
problemMessage: "The '#string' language feature is disabled for this library."
correctionMessage: "Try removing the `@dart=` annotation or setting the language version to #string2 or higher."
script: |
// @dart=2.14
class Foo {}
bar() {
var baz = Foo.new;
}
exampleAllowOtherCodes: true
ExperimentOptOutImplicit:
parameters:
String string: undocumented
String string2: undocumented
problemMessage: "The '#string' language feature is disabled for this library."
correctionMessage: "Try removing the package language version or setting the language version to #string2 or higher."
script:
.dart_tool/package_config.json: |
{
"configVersion": 2,
"packages": [
{
"name": "foo",
"rootUri": "../foo/",
"languageVersion": "2.14"
}
]
}
main.dart: |
import 'package:foo/lib.dart';
foo/lib.dart: |
class Foo {}
bar() {
var baz = Foo.new;
}
exampleAllowOtherCodes: true
ExperimentOptOutComment:
parameters:
String string: undocumented
problemMessage: "This is the annotation that opts out this library from the '#string' language feature."
severity: CONTEXT
AwaitInLateLocalInitializer:
parameters: none
problemMessage: "`await` expressions are not supported in late local initializers."
script: |
Future<void> foo() async {
late dynamic x = await null;
}
NullableSuperclassError:
parameters:
Name name: undocumented
problemMessage: "Can't extend '#name' because it's nullable."
correctionMessage: "Try removing the question mark."
script: |
class Foo extends Object? {}
NullableInterfaceError:
parameters:
Name name: undocumented
problemMessage: "Can't implement '#name' because it's nullable."
correctionMessage: "Try removing the question mark."
script: |
class Foo {}
class Bar implements Foo? {}
NullableMixinError:
parameters:
Name name: undocumented
problemMessage: "Can't mix '#name' in because it's nullable."
correctionMessage: "Try removing the question mark."
script: |
mixin Foo {}
class Bar = Object with Foo?;
JsInteropDartClassExtendsJSClass:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "Dart class '#name' cannot extend JS interop class '#name2'."
correctionMessage: "Try adding the JS interop annotation or removing it from the parent class."
JsInteropDartJsInteropAnnotationForStaticInteropOnly:
parameters: none
problemMessage: "The '@JS' annotation from 'dart:js_interop' can only be used for static interop, either through extension types or '@staticInterop' classes."
correctionMessage: "Try making this class an extension type or marking it as '@staticInterop'."
JsInteropDisallowedInteropLibraryInDart2Wasm:
parameters:
Name name: undocumented
problemMessage: "JS interop library '#name' can't be imported when compiling to Wasm."
correctionMessage: "Try using 'dart:js_interop' or 'dart:js_interop_unsafe' instead."
JsInteropEnclosingClassJSAnnotation:
parameters: none
problemMessage: "Member has a JS interop annotation but the enclosing class does not."
correctionMessage: "Try adding the annotation to the enclosing class."
JsInteropEnclosingClassJSAnnotationContext:
parameters: none
problemMessage: "This is the enclosing class."
severity: CONTEXT
JsInteropExportClassNotMarkedExportable:
parameters:
Name name: undocumented
problemMessage: "Class '#name' does not have a `@JSExport` on it or any of its members."
correctionMessage: "Use the `@JSExport` annotation on this class."
JsInteropExportDartInterfaceHasNonEmptyJSExportValue:
parameters:
Name name: undocumented
problemMessage: "The value in the `@JSExport` annotation on the class or mixin '#name' will be ignored."
correctionMessage: "Remove the value in the annotation."
severity: WARNING
JsInteropExportDisallowedMember:
parameters:
Name name: undocumented
problemMessage: "Member '#name' is not a concrete instance member or declares type parameters, and therefore can't be exported."
correctionMessage: "Remove the `@JSExport` annotation from the member, and use an instance member to call this member instead."
JsInteropExportInvalidInteropTypeArgument:
parameters:
Type type: undocumented
problemMessage: "Type argument '#type' needs to be a non-JS interop type."
correctionMessage: "Use a non-JS interop class that uses `@JSExport` instead."
JsInteropExportInvalidTypeArgument:
parameters:
Type type: undocumented
problemMessage: "Type argument '#type' needs to be an interface type."
correctionMessage: "Use a non-JS interop class that uses `@JSExport` instead."
JsInteropExportMemberCollision:
parameters:
Name name: undocumented
String string: undocumented
problemMessage: "The following class members collide with the same export '#name': #string."
correctionMessage: "Either remove the conflicting members or use a different export name."
JsInteropExportNoExportableMembers:
parameters:
Name name: undocumented
problemMessage: "Class '#name' has no exportable members in the class or the inheritance chain."
correctionMessage: "Using `@JSExport`, annotate at least one instance member with a body or annotate a class that has such a member in the inheritance chain."
JsInteropIsAInvalidTypeVariable:
parameters:
Type type: undocumented
problemMessage: "Type argument '#type' provided to 'isA' cannot be a type variable and must be an interop extension type that can be determined at compile-time."
correctionMessage: "Use a valid interop extension type that can be determined at compile-time as the type argument instead."
JsInteropIsAObjectLiteralType:
parameters:
Type type: undocumented
problemMessage: "Type argument '#type' has an object literal constructor. Because 'isA' uses the type's name or '@JS()' rename, this may result in an incorrect type check."
correctionMessage: "Use 'JSObject' as the type argument instead."
JsInteropIsAPrimitiveExtensionType:
parameters:
Type type: undocumented
String string: undocumented
problemMessage: "Type argument '#type' wraps primitive JS type '#string', which is specially handled using 'typeof'."
correctionMessage: "Use the primitive JS type '#string' as the type argument instead."
JsInteropIsATearoff:
parameters: none
problemMessage: "'isA' can't be torn off."
correctionMessage: "Use a method that calls 'isA' and tear off that method instead."
JsInteropExtensionTypeNotInterop:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "Extension type '#name' is marked with a '@JS' annotation, but its representation type is not a valid JS interop type: '#type'."
correctionMessage: "Try declaring a valid JS interop representation type, which may include 'dart:js_interop' types, '@staticInterop' types, 'dart:html' types, or other interop extension types."
JsInteropExtensionTypeMemberNotInterop:
parameters: none
problemMessage: "Extension type member is marked 'external', but the representation type of its extension type is not a valid JS interop type."
correctionMessage: "Try declaring a valid JS interop representation type, which may include 'dart:js_interop' types, '@staticInterop' types, 'dart:html' types, or other interop extension types."
JsInteropExtensionTypeUsedWithWrongJsAnnotation:
parameters: none
problemMessage: "Extension types should use the '@JS' annotation from 'dart:js_interop' and not from 'package:js'."
correctionMessage: "Try using the '@JS' annotation from 'dart:js_interop' annotation on this extension type instead."
JsInteropExternalExtensionMemberOnTypeInvalid:
parameters: none
problemMessage: "JS interop type or @Native type from an SDK web library required for 'external' extension members."
correctionMessage: "Try making the on-type a JS interop type or an @Native SDK web library type."
JsInteropExternalExtensionMemberWithStaticDisallowed:
parameters: none
problemMessage: "External extension members with the keyword 'static' on JS interop and @Native types are disallowed."
correctionMessage: "Try putting the member in the on-type instead."
JsInteropExternalMemberNotJSAnnotated:
parameters: none
problemMessage: "Only JS interop members may be 'external'."
correctionMessage: "Try removing the 'external' keyword or adding a JS interop annotation."
JsInteropFunctionToJSNamedParameters:
parameters: none
problemMessage: "Functions converted via `toJS` cannot declare named parameters."
correctionMessage: "Remove the declared named parameters from the function."
JsInteropFunctionToJSRequiresStaticType:
parameters:
Type type: undocumented
problemMessage: "`Function.toJS` requires a statically known function type, but Type '#type' is not a precise function type, e.g., `void Function()`."
correctionMessage: "Insert an explicit cast to the expected function type."
JsInteropFunctionToJSTypeParameters:
parameters: none
problemMessage: "Functions converted via `toJS` cannot declare type parameters."
correctionMessage: "Remove the declared type parameters from the function."
JsInteropInvalidStaticClassMemberName:
parameters: none
problemMessage: "JS interop static class members cannot have '.' in their JS name."
JsInteropJSClassExtendsDartClass:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "JS interop class '#name' cannot extend Dart class '#name2'."
correctionMessage: "Try removing the JS interop annotation or adding it to the parent class."
JsInteropNamedParameters:
parameters: none
problemMessage: "Named parameters for JS interop functions are only allowed in object literal constructors or @anonymous factories."
correctionMessage: "Try replacing them with normal or optional parameters."
JsInteropNativeClassInAnnotation:
parameters:
Name name: undocumented
Name name2: undocumented
String string3: undocumented
problemMessage: "Non-static JS interop class '#name' conflicts with natively supported class '#name2' in '#string3'."
correctionMessage: "Try replacing it with a static JS interop class using `@staticInterop` with extension methods, or use js_util to interact with the native object of type '#name2'."
JsInteropNonExternalConstructor:
parameters: none
problemMessage: "JS interop classes do not support non-external constructors."
correctionMessage: "Try annotating with `external`."
JsInteropNonExternalMember:
parameters: none
problemMessage: "This JS interop member must be annotated with `external`. Only factories and static methods can be non-external."
correctionMessage: "Try annotating the member with `external`."
JsInteropObjectLiteralConstructorPositionalParameters:
parameters:
String string: undocumented
problemMessage: "#string should not contain any positional parameters."
correctionMessage: "Try replacing them with named parameters instead."
JsInteropOperatorCannotBeRenamed:
parameters: none
problemMessage: "JS interop operator methods cannot be renamed using the '@JS' annotation."
correctionMessage: "Remove the annotation or remove the value inside the annotation."
JsInteropOperatorsNotSupported:
parameters: none
problemMessage: "JS interop types do not support overloading external operator methods, with the exception of '[]' and '[]=' using static interop."
correctionMessage: "Try making this class a static interop type instead."
JsInteropNonStaticWithStaticInteropSupertype:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "Class '#name' does not have an `@staticInterop` annotation, but has supertype '#name2', which does."
correctionMessage: "Try marking '#name' as a `@staticInterop` class, or don't inherit '#name2'."
# TODO(srujzs): Is there any way to save the correction message into a variable
# to avoid duplication?
JsInteropStaticInteropExternalAccessorTypeViolation:
parameters:
Type type: undocumented
problemMessage: "External JS interop member contains an invalid type: '#type'."
correctionMessage: "Use one of these valid types instead: JS types from 'dart:js_interop', ExternalDartReference, void, bool, num, double, int, String, extension types that erase to one of these types, '@staticInterop' types, 'dart:html' types when compiling to JS, or a type parameter that is a subtype of a valid non-primitive type."
JsInteropStaticInteropExternalFunctionTypeViolation:
parameters:
String string2: undocumented
problemMessage: "External JS interop member contains invalid types in its function signature: '#string2'."
correctionMessage: "Use one of these valid types instead: JS types from 'dart:js_interop', ExternalDartReference, void, bool, num, double, int, String, extension types that erase to one of these types, '@staticInterop' types, 'dart:html' types when compiling to JS, or a type parameter that is a subtype of a valid non-primitive type."
JsInteropStaticInteropToJSFunctionTypeViolation:
parameters:
String string2: undocumented
problemMessage: "Function converted via 'toJS' contains invalid types in its function signature: '#string2'."
correctionMessage: "Use one of these valid types instead: JS types from 'dart:js_interop', ExternalDartReference, void, bool, num, double, int, String, extension types that erase to one of these types, '@staticInterop' types, 'dart:html' types when compiling to JS, or a type parameter that is a subtype of a valid non-primitive type."
JsInteropStaticInteropGenerativeConstructor:
parameters: none
problemMessage: "`@staticInterop` classes should not contain any generative constructors."
correctionMessage: "Use factory constructors instead."
JsInteropStaticInteropMockMissingGetterOrSetter:
parameters:
Name name: undocumented
String string: undocumented
String string2: undocumented
Name name2: undocumented
String string3: undocumented
problemMessage: "Dart class '#name' has a #string, but does not have a #string2 to implement any of the following extension member(s) with export name '#name2': #string3."
correctionMessage: "Declare an exportable #string2 that implements one of these extension members."
JsInteropStaticInteropMockMissingImplements:
parameters:
Name name: undocumented
Name name2: undocumented
String string: undocumented
problemMessage: "Dart class '#name' does not have any members that implement any of the following extension member(s) with export name '#name2': #string."
correctionMessage: "Declare an exportable member that implements one of these extension members."
JsInteropStaticInteropMockNotStaticInteropType:
parameters:
Type type: undocumented
problemMessage: "Type argument '#type' needs to be a `@staticInterop` type."
correctionMessage: "Use a `@staticInterop` class instead."
JsInteropStaticInteropMockTypeParametersNotAllowed:
parameters:
Type type: undocumented
problemMessage: "Type argument '#type' has type parameters that do not match their bound. createStaticInteropMock requires instantiating all type parameters to their bound to ensure mocking conformance."
correctionMessage: "Remove the type parameter in the type argument or replace it with its bound."
JsInteropStaticInteropNoJSAnnotation:
parameters:
Name name: undocumented
problemMessage: "`@staticInterop` classes should also have the `@JS` annotation."
correctionMessage: "Add `@JS` to class '#name'."
JsInteropStaticInteropParameterInitializersAreIgnored:
parameters: none
problemMessage: "Initializers for parameters are ignored on static interop external functions."
correctionMessage: "Declare a forwarding non-external function with this initializer, or remove the initializer."
severity: WARNING
JsInteropStaticInteropSyntheticConstructor:
parameters: none
problemMessage: "Synthetic constructors on `@staticInterop` classes can not be used."
correctionMessage: "Declare an external factory constructor for this `@staticInterop` class and use that instead."
JsInteropStaticInteropTearOffsDisallowed:
parameters:
String string: undocumented
Name name: undocumented
problemMessage: "Tear-offs of external #string '#name' are disallowed."
correctionMessage: "Declare a closure that calls this member instead."
JsInteropStaticInteropTrustTypesUsedWithoutStaticInterop:
parameters:
Name name: undocumented
problemMessage: "JS interop class '#name' has an `@trustTypes` annotation, but no `@staticInterop` annotation."
correctionMessage: "Try marking the class using `@staticInterop`."
JsInteropStaticInteropTrustTypesUsageNotAllowed:
parameters:
Name name: undocumented
problemMessage: "JS interop class '#name' has an `@trustTypes` annotation, but `@trustTypes` is only supported within the sdk."
correctionMessage: "Try removing the `@trustTypes` annotation."
JsInteropStaticInteropWithInstanceMembers:
parameters:
Name name: undocumented
problemMessage: "JS interop class '#name' with `@staticInterop` annotation cannot declare instance members."
correctionMessage: "Try moving the instance member to a static extension."
JsInteropStaticInteropWithNonStaticSupertype:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "JS interop class '#name' has an `@staticInterop` annotation, but has supertype '#name2', which does not."
correctionMessage: "Try marking the supertype as a static interop class using `@staticInterop`."
NonNullableNotAssignedError:
parameters:
Name name: undocumented
problemMessage: "Non-nullable variable '#name' must be assigned before it can be used."
script: |
method<T>() {
T t; t;
}
FinalNotAssignedError:
parameters:
Name name: undocumented
problemMessage: "Final variable '#name' must be assigned before it can be used."
analyzerCode: READ_POTENTIALLY_UNASSIGNED_FINAL
script: |
method(bool b) {
final int i;
if (b) {
i = 0;
}
i;
}
LateDefinitelyUnassignedError:
parameters:
Name name: undocumented
problemMessage: "Late variable '#name' without initializer is definitely unassigned."
script: |
method<T>() {
late T t; t;
}
LateDefinitelyAssignedError:
parameters:
Name name: undocumented
problemMessage: "Late final variable '#name' definitely assigned."
script: |
method() {
late final int t;
t = 0;
t = 0;
}
FinalPossiblyAssignedError:
parameters:
Name name: undocumented
problemMessage: "Final variable '#name' might already be assigned at this point."
analyzerCode: ASSIGNMENT_TO_FINAL_LOCAL
script: |
method() {
final int i;
i = 0;
i = 0;
}
CannotAssignToFinalVariable:
parameters:
Name name: undocumented
problemMessage: "Can't assign to the final variable '#name'."
script: |
main() {
final int i = 0;
i = 42;
}
CannotAssignToConstVariable:
parameters:
Name name: undocumented
problemMessage: "Can't assign to the const variable '#name'."
script: |
main() {
const int i = 0;
i = 42;
}
CannotAssignToExtensionThis:
parameters: none
problemMessage: "Can't assign to 'this'."
script: |
extension E on String {
method() {
this = "";
}
}
CannotAssignToTypeLiteral:
parameters: none
problemMessage: "Can't assign to a type literal."
script: |
main() {
Object = String;
}
NonVoidReturnOperator:
parameters: none
problemMessage: "The return type of the operator []= must be 'void'."
correctionMessage: "Try changing the return type to 'void'."
analyzerCode: NON_VOID_RETURN_FOR_OPERATOR
script:
- class Class { int operator[]=(a, b) {} }
- class Class { dynamic operator[]=(a, b) {} }
NonVoidReturnSetter:
parameters: none
problemMessage: "The return type of the setter must be 'void' or absent."
correctionMessage: "Try removing the return type, or define a method rather than a setter."
analyzerCode: NON_VOID_RETURN_FOR_SETTER
script:
- int set setter(_) {}
- dynamic set setter(_) {}
NeverReachableSwitchDefaultError:
parameters: none
problemMessage: "`null` encountered as case in a switch expression with a non-nullable enum type."
NeverReachableSwitchExpressionError:
parameters: none
problemMessage: "`null` encountered as case in a switch expression with a non-nullable type."
NeverReachableSwitchStatementError:
parameters: none
problemMessage: "`null` encountered as case in a switch statement with a non-nullable type."
UnsoundSwitchExpressionError:
parameters: none
problemMessage: "None of the patterns in the switch expression the matched input value. See https://github.com/dart-lang/language/issues/3488 for details."
UnsoundSwitchStatementError:
parameters: none
problemMessage: "None of the patterns in the exhaustive switch statement the matched input value. See https://github.com/dart-lang/language/issues/3488 for details."
NeverValueError:
parameters: none
problemMessage: "`null` encountered as the result from expression with type `Never`."
MainNotFunctionDeclaration:
parameters: none
problemMessage: "The 'main' declaration must be a function declaration."
script:
- var main;
MainNotFunctionDeclarationExported:
parameters: none
problemMessage: "The exported 'main' declaration must be a function declaration."
exampleAllowOtherCodes: true
script:
main.dart:
export 'lib.dart';
lib.dart:
var main;
MainTooManyRequiredParameters:
parameters: none
problemMessage: "The 'main' method must have at most 2 required parameters."
script:
- main(a, b, c) {}
MainTooManyRequiredParametersExported:
parameters: none
problemMessage: "The exported 'main' method must have at most 2 required parameters."
exampleAllowOtherCodes: true
script:
main.dart:
export 'lib.dart';
lib.dart:
main(a, b, c) {}
MainRequiredNamedParameters:
parameters: none
problemMessage: "The 'main' method cannot have required named parameters."
script:
- main({required a}) {}
MainRequiredNamedParametersExported:
parameters: none
problemMessage: "The exported 'main' method cannot have required named parameters."
exampleAllowOtherCodes: true
script:
main.dart:
export 'lib.dart';
lib.dart:
main({required a}) {}
MainWrongParameterType:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The type '#type' of the first parameter of the 'main' method is not a supertype of '#type2'."
script:
- main(Set<String> args) {}
MainWrongParameterTypeExported:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The type '#type' of the first parameter of the exported 'main' method is not a supertype of '#type2'."
exampleAllowOtherCodes: true
script:
main.dart:
export 'lib.dart';
lib.dart:
main(Set<String> args) {}
ExportedMain:
parameters: none
problemMessage: "This is exported 'main' declaration."
severity: CONTEXT
UnsupportedDartExt:
parameters: none
problemMessage: "Dart native extensions are no longer supported."
correctionMessage: "Migrate to using FFI instead (https://dart.dev/guides/libraries/c-interop)"
script: |
import 'dart-ext:foo.dart';
InstantiationNonGenericFunctionType:
parameters:
Type type: undocumented
problemMessage: "The static type of the explicit instantiation operand must be a generic function type but is '#type'."
correctionMessage: "Try changing the operand or remove the type arguments."
script: |
f() {}
main() => f<int>;
InstantiationNullableGenericFunctionType:
parameters:
Type type: undocumented
problemMessage: "The static type of the explicit instantiation operand must be a non-null generic function type but is '#type'."
correctionMessage: "Try changing the operand or remove the type arguments."
analyzerCode: DISALLOWED_TYPE_INSTANTIATION_EXPRESSION
script: |
test(void Function<T>()? f) => f<int>;
InstantiationTooFewArguments:
parameters:
int count: undocumented
int count2: undocumented
problemMessage: "Too few type arguments: #count required, #count2 given."
correctionMessage: "Try adding the missing type arguments."
script: |
f<X, Y>() {}
main() => f<int>;
InstantiationTooManyArguments:
parameters:
int count: undocumented
int count2: undocumented
problemMessage: "Too many type arguments: #count allowed, but #count2 found."
correctionMessage: "Try removing the extra type arguments."
script: |
f<X>() {}
main() => f<int, String>;
AbstractClassConstructorTearOff:
parameters: none
problemMessage: "Constructors on abstract classes can't be torn off."
script: |
abstract class Class {}
main() => Class.new;
StaticTearOffFromInstantiatedClass:
parameters: none
problemMessage: "Cannot access static member on an instantiated generic class."
correctionMessage: "Try removing the type arguments or placing them after the member name."
script: |
class A<X> { static f() {} }
main() => A<int>.f;
ConstructorTearOffWithTypeArguments:
parameters: none
problemMessage: "A constructor tear-off can't have type arguments after the constructor name."
correctionMessage: "Try removing the type arguments or placing them after the class name."
script:
- "class C<X> { C.foo(); } bar() { C.foo<int>; }"
NewAsSelector:
parameters: none
problemMessage: "'new' can only be used as a constructor reference."
script: |
method(dynamic d) => d.new;
PositionalSuperParametersAndArguments:
parameters: none
problemMessage: "Positional super-initializer parameters cannot be used when the super initializer has positional arguments."
script: |
class Foo {
Foo(int foo);
}
class Bar extends Foo {
Bar(super.foo) : super(42);
}
SuperInitializerParameter:
parameters: none
problemMessage: "This is the super-initializer parameter."
severity: CONTEXT
EnumSupertypeOfNonAbstractClass:
parameters:
Name name: undocumented
problemMessage: "Non-abstract class '#name' has 'Enum' as a superinterface."
script: |
class Foo extends Enum {
int get index => 42;
}
exampleAllowOtherCodes: true
EnumNonConstConstructor:
parameters: none
problemMessage: "Generative enum constructors must be marked as 'const'."
script: |
enum Foo {
bar;
Foo();
}
exampleAllowOtherCodes: true
EnumConstructorSuperInitializer:
parameters: none
problemMessage: "Enum constructors can't contain super-initializers."
script: |
enum E2 {
one.named1();
const E2.named1() : super();
}
EnumConstructorTearoff:
parameters: none
problemMessage: "Enum constructors can't be torn off."
script: |
enum Foo { a, b, c}
void bar() {
Foo.new;
}
EnumFactoryRedirectsToConstructor:
parameters: none
problemMessage: "Enum factory constructors can't redirect to generative constructors."
script: |
enum E {
a, b, c;
const factory E.f3() = E;
}
EnumContainsValuesDeclaration:
parameters: none
problemMessage: "An enum can't declare a member named 'values'."
script: |
enum E1 {
element;
static const List<E1> values = [E1.element];
}
EnumImplementerContainsValuesDeclaration:
parameters:
Name name: undocumented
problemMessage: "'#name' has 'Enum' as a superinterface and can't contain non-static member with name 'values'."
script: |
mixin M1 on Enum {
final int values = 42;
}
EnumInheritsRestricted:
parameters:
Name name: undocumented
problemMessage: "An enum can't inherit a member named '#name'."
script: |
mixin class A1 {
int get hashCode => 42;
}
enum E1 with A1 {
element
}
EnumInheritsRestrictedMember:
parameters: none
problemMessage: "This is the inherited member"
severity: CONTEXT
UnmatchedAugmentationClassMember:
parameters:
Name name: undocumented
problemMessage: "Augmentation member '#name' doesn't match a member in the augmented class."
correctionMessage: "Try changing the name to an existing member or removing the 'augment' modifier."
experiments: augmentations
UnmatchedPatchClassMember:
parameters:
Name name: undocumented
problemMessage: "Patch member '#name' doesn't match a member in the origin class."
correctionMessage: "Try changing the name to an existing member or removing the '@patch' annotation."
UnmatchedAugmentationLibraryMember:
parameters:
Name name: undocumented
problemMessage: "Augmentation member '#name' doesn't match a member in the augmented library."
correctionMessage: "Try changing the name to an existing member or removing the 'augment' modifier."
experiments: augmentations
UnmatchedPatchLibraryMember:
parameters:
Name name: undocumented
problemMessage: "Patch member '#name' doesn't match a member in the origin library."
correctionMessage: "Try changing the name to an existing member or removing the '@patch' annotation."
UnmatchedAugmentationClass:
parameters:
Name name: undocumented
problemMessage: "Augmentation class '#name' doesn't match a class in the augmented library."
correctionMessage: "Try changing the name to an existing class or removing the 'augment' modifier."
experiments: augmentations
UnmatchedPatchClass:
parameters:
Name name: undocumented
problemMessage: "Patch class '#name' doesn't match a class in the origin library."
correctionMessage: "Try changing the name to an existing class or removing the '@patch' annotation."
UnmatchedAugmentationDeclaration:
parameters:
Name name: undocumented
problemMessage: "Augmentation '#name' doesn't match a declaration in the augmented library."
correctionMessage: "Try changing the name to an existing declaration or removing the 'augment' modifier."
experiments: macros
UnmatchedPatchDeclaration:
parameters:
Name name: undocumented
problemMessage: "Patch '#name' doesn't match a declaration in the origin library."
correctionMessage: "Try changing the name to an existing declaration or removing the '@patch' annotation."
UnmatchedAugmentationConstructor:
parameters:
Name name: undocumented
problemMessage: "Augmentation constructor '#name' doesn't match a constructor in the augmented class."
correctionMessage: "Try changing the name to an existing constructor or removing the 'augment' modifier."
experiments: augmentations
NonAugmentationMemberConflictCause:
parameters: none
problemMessage: "This is the existing member."
severity: CONTEXT
NonAugmentationDeclarationConflictCause:
parameters: none
problemMessage: "This is the existing declaration."
severity: CONTEXT
OptionalSuperParameterWithoutInitializer:
parameters:
Type type: undocumented
Name name: undocumented
problemMessage: "Type '#type' of the optional super-initializer parameter '#name' doesn't allow 'null', but the parameter doesn't have a default value, and the default value can't be copied from the corresponding parameter of the super constructor."
script: |
class Foo {
Foo([num x = 3.14]) {}
}
class Bar extends Foo {
Bar([int super.x]);
}
EnumContainsRestrictedInstanceDeclaration:
parameters:
Name name: undocumented
problemMessage: "An enum can't declare a non-abstract member named '#name'."
script: |
enum E1 {
element;
bool operator==(Object other) => true;
}
EnumImplementerContainsRestrictedInstanceDeclaration:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "'#name' has 'Enum' as a superinterface and can't contain non-static members with name '#name2'."
script: |
class Foo extends Enum {
int get index => 42;
}
exampleAllowOtherCodes: true
EnumAbstractMember:
parameters: none
problemMessage: "Enums can't declare abstract members."
script: |
enum E1 {
element;
void foo();
}
MixinInheritsFromNotObject:
parameters:
Name name: undocumented
problemMessage: "The class '#name' can't be used as a mixin because it extends a class other than 'Object'."
analyzerCode: MIXIN_INHERITS_FROM_NOT_OBJECT
script: |
// @dart=2.19
class Base {}
class Mixin extends Base {}
class C extends Base with Mixin {}
MixinApplicationNoConcreteMethod:
parameters:
Name name: undocumented
problemMessage: "The class doesn't have a concrete implementation of the super-invoked member '#name'."
analyzerCode: MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER
script: |
class Super {
void method() {}
}
mixin Mixin on Super {
void method() {
super.method();
}
}
abstract class AbstractSuper implements Super {}
class Class extends AbstractSuper with Mixin {}
MixinApplicationNoConcreteGetter:
parameters:
Name name: undocumented
problemMessage: "The class doesn't have a concrete implementation of the super-accessed member '#name'."
analyzerCode: MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER
script: |
class Super {
int get getter => 42;
}
mixin Mixin on Super {
int get getter {
return super.getter;
}
}
abstract class AbstractSuper implements Super {}
class Class extends AbstractSuper with Mixin {}
MixinApplicationNoConcreteSetter:
parameters:
Name name: undocumented
problemMessage: "The class doesn't have a concrete implementation of the super-accessed setter '#name'."
analyzerCode: MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER
script: |
class Super {
void set setter(int value) {}
}
mixin Mixin on Super {
void set setter(int value) {
super.setter = value;
}
}
abstract class AbstractSuper implements Super {}
class Class extends AbstractSuper with Mixin {}
MixinApplicationNoConcreteMemberContext:
parameters: none
problemMessage: "This is the super-access that doesn't have a concrete target."
severity: CONTEXT
NoAugmentSuperReadTarget:
parameters: none
problemMessage: "Cannot read from 'augment super'."
experiments: augmentations
NoAugmentSuperWriteTarget:
parameters: none
problemMessage: "Cannot write to 'augment super'."
experiments: augmentations
NoAugmentSuperInvokeTarget:
parameters: none
problemMessage: "Cannot call 'augment super'."
experiments: augmentations
IndexOutOfBoundInRecordIndexGet:
parameters:
int count: undocumented
int count2: undocumented
Type type: undocumented
problemMessage: "Index #count is out of range 0..#count2 of positional fields of records #type."
NameNotFoundInRecordNameGet:
parameters:
String string: undocumented
Type type: undocumented
problemMessage: "Field name #string isn't found in records of type #type."
ObjectMemberNameUsedForRecordField:
parameters: none
problemMessage: "Record field names can't be the same as a member from 'Object'."
script: |
(int hashCode,) foo1() => throw 0;
RecordFieldsCantBePrivate:
parameters: none
problemMessage: "Record field names can't be private."
analyzerCode: INVALID_FIELD_NAME
script: |
foo() => (_bar: 1);
NamedFieldClashesWithPositionalFieldInRecord:
parameters: none
problemMessage: "Record field names can't be a dollar sign followed by an integer when integer is the index of a positional field."
analyzerCode: INVALID_FIELD_NAME
script: |
foo() => (0, $1: 0);
EnumWithNameValues:
parameters: none
problemMessage: "The name 'values' is not a valid name for an enum. Try using a different name."
analyzerCode: ENUM_WITH_NAME_VALUES
script: |
enum values {
foo, bar;
}
exampleAllowOtherCodes: true
InheritedRestrictedMemberOfEnumImplementer:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "A concrete instance member named '#name' can't be inherited from '#name2' in a class that implements 'Enum'."
analyzerCode: ILLEGAL_CONCRETE_ENUM_MEMBER
script: |
abstract class A { int get hashCode => 0; }
abstract class B extends A implements Enum {}
SealedClassSubtypeOutsideOfLibrary:
parameters:
Name name: undocumented
problemMessage: "The class '#name' can't be extended, implemented, or mixed in outside of its library because it's a sealed class."
analyzerCode: SEALED_CLASS_SUBTYPE_OUTSIDE_OF_LIBRARY
script:
main.dart:
import 'lib.dart';
class B extends A {}
lib.dart:
sealed class A {}
CantUseClassAsMixin:
parameters:
Name name: undocumented
problemMessage: "The class '#name' can't be used as a mixin because it isn't a mixin class nor a mixin."
analyzerCode: CLASS_USED_AS_MIXIN
script:
main.dart:
import 'lib.dart';
class B with A {}
lib.dart:
class A {}
BaseEnum:
parameters: none
index: 155
problemMessage: "Enums can't be declared to be 'base'."
correctionMessage: "Try removing the keyword 'base'."
analyzerCode: ParserErrorCode.BASE_ENUM
script:
- "base enum E { v }"
FinalEnum:
parameters: none
index: 156
problemMessage: "Enums can't be declared to be 'final'."
correctionMessage: "Try removing the keyword 'final'."
analyzerCode: ParserErrorCode.FINAL_ENUM
script:
- "final enum E { v }"
InterfaceEnum:
parameters: none
index: 157
problemMessage: "Enums can't be declared to be 'interface'."
correctionMessage: "Try removing the keyword 'interface'."
analyzerCode: ParserErrorCode.INTERFACE_ENUM
script:
- "interface enum E { v }"
SealedEnum:
parameters: none
index: 158
problemMessage: "Enums can't be declared to be 'sealed'."
correctionMessage: "Try removing the keyword 'sealed'."
analyzerCode: ParserErrorCode.SEALED_ENUM
script:
- "sealed enum E { v }"
FinalMixin:
parameters: none
index: 146
problemMessage: "A mixin can't be declared 'final'."
correctionMessage: "Try removing the 'final' keyword."
analyzerCode: ParserErrorCode.FINAL_MIXIN
script:
- "final mixin M {}"
InterfaceMixin:
parameters: none
index: 147
problemMessage: "A mixin can't be declared 'interface'."
correctionMessage: "Try removing the 'interface' keyword."
analyzerCode: ParserErrorCode.INTERFACE_MIXIN
script:
- "interface mixin M {}"
SealedMixin:
parameters: none
index: 148
problemMessage: "A mixin can't be declared 'sealed'."
correctionMessage: "Try removing the 'sealed' keyword."
analyzerCode: ParserErrorCode.SEALED_MIXIN
script:
- "sealed mixin M {}"
FinalMixinClass:
parameters: none
index: 142
problemMessage: "A mixin class can't be declared 'final'."
correctionMessage: "Try removing the 'final' keyword."
analyzerCode: ParserErrorCode.FINAL_MIXIN_CLASS
script:
- "final mixin class C {}"
InterfaceMixinClass:
parameters: none
index: 143
problemMessage: "A mixin class can't be declared 'interface'."
correctionMessage: "Try removing the 'interface' keyword."
analyzerCode: ParserErrorCode.INTERFACE_MIXIN_CLASS
script:
- "interface mixin class C {}"
SealedMixinClass:
parameters: none
index: 144
problemMessage: "A mixin class can't be declared 'sealed'."
correctionMessage: "Try removing the 'sealed' keyword."
analyzerCode: ParserErrorCode.SEALED_MIXIN_CLASS
script:
- "sealed mixin class C {}"
BaseClassImplementedOutsideOfLibrary:
parameters:
Name name: undocumented
problemMessage: "The class '#name' can't be implemented outside of its library because it's a base class."
analyzerCode: BASE_CLASS_IMPLEMENTED_OUTSIDE_OF_LIBRARY
script:
main.dart:
import 'lib.dart';
base class B implements A {}
lib.dart:
base class A {}
BaseOrFinalClassImplementedOutsideOfLibraryCause:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "The type '#name' is a subtype of '#name2', and '#name2' is defined here."
severity: CONTEXT
BaseMixinImplementedOutsideOfLibrary:
parameters:
Name name: undocumented
problemMessage: "The mixin '#name' can't be implemented outside of its library because it's a base mixin."
analyzerCode: BASE_MIXIN_IMPLEMENTED_OUTSIDE_OF_LIBRARY
script:
main.dart:
import 'lib.dart';
base class B implements A {}
lib.dart:
base mixin A {}
InterfaceClassExtendedOutsideOfLibrary:
parameters:
Name name: undocumented
problemMessage: "The class '#name' can't be extended outside of its library because it's an interface class."
analyzerCode: INTERFACE_CLASS_EXTENDED_OUTSIDE_OF_LIBRARY
script:
main.dart:
import 'lib.dart';
class B extends A {}
lib.dart:
interface class A {}
FinalClassExtendedOutsideOfLibrary:
parameters:
Name name: undocumented
problemMessage: "The class '#name' can't be extended outside of its library because it's a final class."
analyzerCode: FINAL_CLASS_EXTENDED_OUTSIDE_OF_LIBRARY
script:
main.dart:
import 'lib.dart';
final class B extends A {}
lib.dart:
final class A {}
FinalClassImplementedOutsideOfLibrary:
parameters:
Name name: undocumented
problemMessage: "The class '#name' can't be implemented outside of its library because it's a final class."
analyzerCode: FINAL_CLASS_IMPLEMENTED_OUTSIDE_OF_LIBRARY
script:
main.dart:
import 'lib.dart';
final class B implements A {}
lib.dart:
final class A {}
FinalClassUsedAsMixinConstraintOutsideOfLibrary:
parameters:
Name name: undocumented
problemMessage: "The class '#name' can't be used as a mixin superclass constraint outside of its library because it's a final class."
analyzerCode: FINAL_CLASS_USED_AS_MIXIN_CONSTRAINT_OUTSIDE_OF_LIBRARY
script:
main.dart:
import 'lib.dart';
base mixin B on A {}
lib.dart:
final class A {}
SubtypeOfBaseIsNotBaseFinalOrSealed:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "The type '#name' must be 'base', 'final' or 'sealed' because the supertype '#name2' is 'base'."
correctionMessage: "Try adding 'base', 'final', or 'sealed' to the type."
analyzerCode: SUBTYPE_OF_BASE_IS_NOT_BASE_FINAL_OR_SEALED
script: |
base class A {}
class B extends A {}
SubtypeOfFinalIsNotBaseFinalOrSealed:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "The type '#name' must be 'base', 'final' or 'sealed' because the supertype '#name2' is 'final'."
correctionMessage: "Try adding 'base', 'final', or 'sealed' to the type."
analyzerCode: SUBTYPE_OF_FINAL_IS_NOT_BASE_FINAL_OR_SEALED
script: |
final class A {}
class B extends A {}
MixinSubtypeOfBaseIsNotBase:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "The mixin '#name' must be 'base' because the supertype '#name2' is 'base'."
correctionMessage: "Try adding 'base' to the mixin."
analyzerCode: MIXIN_SUBTYPE_OF_BASE_IS_NOT_BASE
script: |
base class A {}
mixin B implements A {}
MixinSubtypeOfFinalIsNotBase:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "The mixin '#name' must be 'base' because the supertype '#name2' is 'final'."
correctionMessage: "Try adding 'base' to the mixin."
analyzerCode: MIXIN_SUBTYPE_OF_FINAL_IS_NOT_BASE
script: |
final class A {}
mixin B implements A {}
UnspecifiedGetterNameInObjectPattern:
parameters: none
problemMessage: "The getter name is not specified explicitly, and the pattern is not a variable. Try specifying the getter name explicitly, or using a variable pattern."
analyzerCode: MISSING_OBJECT_PATTERN_GETTER_NAME
script: |
abstract class A { int get foo;}
test(dynamic x) { if (x case A(: 0)) {} }
JointPatternVariablesMismatch:
parameters:
Name name: undocumented
problemMessage: "Variable pattern '#name' doesn't have the same type or finality in all cases."
script: |
test(dynamic x) { switch (x) { case [int a]: case [double a] : return a; default: return null; } }
NonExhaustiveSwitchExpression:
parameters:
Type type: undocumented
String string: undocumented
String string2: undocumented
problemMessage: "The type '#type' is not exhaustively matched by the switch cases since it doesn't match '#string'."
correctionMessage: "Try adding a wildcard pattern or cases that match '#string2'."
analyzerCode: NON_EXHAUSTIVE_SWITCH_EXPRESSION
script: |
enum Enum { a, b }
String method(Enum e) => switch (e) {
Enum.a => 'a',
};
NonExhaustiveSwitchStatement:
parameters:
Type type: undocumented
String string: undocumented
String string2: undocumented
problemMessage: "The type '#type' is not exhaustively matched by the switch cases since it doesn't match '#string'."
correctionMessage: "Try adding a default case or cases that match '#string2'."
analyzerCode: NON_EXHAUSTIVE_SWITCH_STATEMENT
script: |
enum Enum { a, b }
method(Enum e) {
switch (e) {
case Enum.a:
break;
}
}
PatternTypeMismatchInIrrefutableContext:
parameters:
Type type: undocumented
Type type2: undocumented
problemMessage: "The matched value of type '#type' isn't assignable to the required type '#type2'."
correctionMessage: "Try changing the required type of the pattern, or the matched value type."
analyzerCode: PATTERN_TYPE_MISMATCH_IN_IRREFUTABLE_CONTEXT
script: |
method(List<String> list) {
var <int>[a] = list;
}
DuplicatePatternAssignmentVariable:
parameters:
Name name: undocumented
problemMessage: The variable '#name' is already assigned in this pattern.
correctionMessage: Try renaming the variable.
analyzerCode: DUPLICATE_PATTERN_ASSIGNMENT_VARIABLE
script: |
method(List<String> list) {
String a = '';
[a, a] = list;
}
DuplicatePatternAssignmentVariableContext:
parameters: none
problemMessage: The first assigned variable pattern.
severity: CONTEXT
DuplicateRecordPatternField:
parameters:
Name name: undocumented
problemMessage: The field '#name' is already matched in this pattern.
correctionMessage: Try removing the duplicate field.
analyzerCode: DUPLICATE_RECORD_PATTERN_FIELD
script: |
method(o) {
switch (o) {
case (field: 1, field: 2):
}
}
DuplicateRecordPatternFieldContext:
parameters: none
problemMessage: The first field.
severity: CONTEXT
DuplicateRestElementInPattern:
parameters: none
problemMessage: At most one rest element is allowed in a list or map pattern.
correctionMessage: Try removing the duplicate rest element.
analyzerCode: DUPLICATE_REST_ELEMENT_IN_PATTERN
script: |
method(o) {
switch (o) {
case [..., ...]:
}
}
DuplicateRestElementInPatternContext:
parameters: none
problemMessage: The first rest element.
severity: CONTEXT
RestPatternInMapPattern:
parameters: none
problemMessage: "The '...' pattern can't appear in map patterns."
script: |
test(dynamic x) { if (x case {1: 1, ...}) {} }
NonBoolCondition:
parameters: none
problemMessage: "Conditions must have a static type of 'bool'."
correctionMessage: Try changing the condition.
analyzerCode: NON_BOOL_CONDITION
script: |
method(int i) {
if (i case 5 when i) {}
}
RefutablePatternInIrrefutableContext:
parameters: none
problemMessage: Refutable patterns can't be used in an irrefutable context.
correctionMessage: Try using an if-case, a 'switch' statement, or a 'switch' expression instead.
analyzerCode: REFUTABLE_PATTERN_IN_IRREFUTABLE_CONTEXT
script: |
method(int? x) {
var (a?) = x;
}
MissingVariablePattern:
parameters:
Name name: undocumented
problemMessage: "Variable pattern '#name' is missing in this branch of the logical-or pattern."
correctionMessage: "Try declaring this variable pattern in the branch."
analyzerCode: MISSING_VARIABLE_PATTERN
script: |
method(x) {
if (x case [var a] || _) {}
}
MapPatternTypeArgumentMismatch:
parameters: none
problemMessage: "A map pattern requires exactly two type arguments."
analyzerCode: EXPECTED_TWO_MAP_PATTERN_TYPE_ARGUMENTS
script: |
method(x) {
if (x case <int>{0: 0}) {}
}
ListPatternTooManyTypeArguments:
parameters: none
problemMessage: "A list pattern requires exactly one type argument."
analyzerCode: EXPECTED_ONE_LIST_PATTERN_TYPE_ARGUMENTS
script: |
method(x) {
if (x case <int, int>[]) {}
}
UnnamedObjectPatternField:
parameters: none
problemMessage: "A pattern field in an object pattern must be named."
correctionMessage: "Try adding a pattern name or ':' before the pattern."
script: |
method(x) {
if (x case int(5)) {}
}
InvalidConstantPatternNegation:
parameters: none
problemMessage: "Only negation of a numeric literal is supported as a constant pattern."
correctionMessage: "Try wrapping the expression in 'const ( ... )'."
analyzerCode: ParserErrorCode.INVALID_CONSTANT_PATTERN_NEGATION
index: 135
script: |
method(x) {
const y = 5;
if (x case -y) {}
}
InvalidConstantPatternUnary:
parameters:
Name name: undocumented
problemMessage: "The unary operator #name is not supported as a constant pattern."
correctionMessage: "Try wrapping the expression in 'const ( ... )'."
analyzerCode: ParserErrorCode.INVALID_CONSTANT_PATTERN_UNARY
index: 136
script: |
method(x) {
const y = false;
if (x case !y) {}
}
InvalidConstantPatternDuplicateConst:
parameters: none
problemMessage: "Duplicate 'const' keyword in constant expression."
correctionMessage: "Try removing one of the 'const' keywords."
analyzerCode: ParserErrorCode.INVALID_CONSTANT_PATTERN_DUPLICATE_CONST
index: 137
script: |
method(x) {
if (x case const const []) {}
}
InvalidConstantPatternEmptyRecordLiteral:
parameters: none
problemMessage: "The empty record literal is not supported as a constant pattern."
analyzerCode: ParserErrorCode.INVALID_CONSTANT_PATTERN_EMPTY_RECORD_LITERAL
index: 138
script: |
method(x) {
if (x case const ()) {}
}
InvalidConstantPatternGeneric:
parameters: none
problemMessage: "This expression is not supported as a constant pattern."
correctionMessage: "Try wrapping the expression in 'const ( ... )'."
analyzerCode: ParserErrorCode.INVALID_CONSTANT_PATTERN_GENERIC
index: 139
script: |
method(x) {
if (x case List<int>) {}
}
InvalidConstantPatternConstPrefix:
parameters: none
problemMessage: "The expression can't be prefixed by 'const' to form a constant pattern."
correctionMessage: "Try wrapping the expression in 'const ( ... )' instead."
analyzerCode: ParserErrorCode.INVALID_CONSTANT_CONST_PREFIX
index: 140
script: |
method(x) {
if (x case const 1) {}
}
InvalidConstantPatternBinary:
parameters:
Name name: undocumented
problemMessage: "The binary operator #name is not supported as a constant pattern."
correctionMessage: "Try wrapping the expression in 'const ( ... )'."
analyzerCode: ParserErrorCode.INVALID_CONSTANT_PATTERN_BINARY
index: 141
script: |
method(x) {
if (x case 1 + 2) {}
}
PatternAssignmentDeclaresVariable:
parameters:
Name name: undocumented
problemMessage: "Variable '#name' can't be declared in a pattern assignment."
correctionMessage: "Try using a preexisting variable or changing the assignment to a pattern variable declaration."
analyzerCode: ParserErrorCode.PATTERN_ASSIGNMENT_DECLARES_VARIABLE
index: 145
script: |
method(x) {
var y;
[y, var z] = x;
}
PatternAssignmentNotLocalVariable:
parameters: none
problemMessage: Only local variables or formal parameters can be used in pattern assignments.
correctionMessage: Try assigning to a local variable.
analyzerCode: PATTERN_ASSIGNMENT_NOT_LOCAL_VARIABLE
script: |
var global;
method(x) {
[global] = x;
}
VariablePatternKeywordInDeclarationContext:
parameters: none
problemMessage: Variable patterns in declaration context can't specify 'var' or 'final' keyword.
correctionMessage: Try removing the keyword.
analyzerCode: ParserErrorCode.VARIABLE_PATTERN_KEYWORD_IN_DECLARATION_CONTEXT
index: 149
comment: No parameters.
hasPublishedDocs: true
script: |
void f((int, int) r) {
var (var x, y) = r;
print(x + y);
}
documentation: |-
#### Description
The analyzer produces this diagnostic when a variable pattern is used
within a declaration context.
#### Example
The following code produces this diagnostic because the variable patterns
in the record pattern are in a declaration context:
```dart
void f((int, int) r) {
var ([!var!] x, y) = r;
print(x + y);
}
```
#### Common fixes
Remove the `var` or `final` keyword(s) within the variable pattern:
```dart
void f((int, int) r) {
var (x, y) = r;
print(x + y);
}
```
IllegalPatternVariableName:
parameters:
Token lexeme: undocumented
problemMessage: The variable declared by a variable pattern can't be named '#lexeme'.
correctionMessage: Choose a different name.
analyzerCode: ParserErrorCode.ILLEGAL_PATTERN_VARIABLE_NAME
index: 159
comment: |-
Parameters:
0: the illegal name
script: |
void f(x) {
switch (x) {
case var when:
}
}
IllegalPatternAssignmentVariableName:
parameters:
Token lexeme: undocumented
problemMessage: A variable assigned by a pattern assignment can't be named '#lexeme'.
correctionMessage: Choose a different name.
analyzerCode: ParserErrorCode.ILLEGAL_PATTERN_ASSIGNMENT_VARIABLE_NAME
index: 160
comment: |-
Parameters:
0: the illegal name
script: |
void f(x) {
dynamic when;
(when) = x;
}
IllegalPatternIdentifierName:
parameters:
Token lexeme: undocumented
problemMessage: A pattern can't refer to an identifier named '#lexeme'.
correctionMessage: Match the identifier using '== #lexeme'.
analyzerCode: ParserErrorCode.ILLEGAL_PATTERN_IDENTIFIER_NAME
index: 161
comment: |-
Parameters:
0: the illegal name
script: |
void f(x) {
const when = 0;
switch (x) {
case when:
}
}
InvalidInsideUnaryPattern:
parameters: none
problemMessage: This pattern cannot appear inside a unary pattern (cast pattern, null check pattern, or null assert pattern) without parentheses.
correctionMessage: Try combining into a single pattern if possible, or enclose the inner pattern in parentheses.
analyzerCode: ParserErrorCode.INVALID_INSIDE_UNARY_PATTERN
index: 150
comment: No parameters.
script: |
void f(x) {
if (x case _ as int as num) {}
}
LatePatternVariableDeclaration:
parameters: none
problemMessage: A pattern variable declaration may not use the `late` keyword.
correctionMessage: Try removing the keyword `late`.
analyzerCode: ParserErrorCode.LATE_PATTERN_VARIABLE_DECLARATION
index: 151
comment: No parameters.
script: |
void f(x) {
late var (y, z) = x;
}
PatternVariableDeclarationOutsideFunctionOrMethod:
parameters: none
problemMessage: A pattern variable declaration may not appear outside a function or method.
correctionMessage: Try declaring ordinary variables and assigning from within a function or method.
analyzerCode: ParserErrorCode.PATTERN_VARIABLE_DECLARATION_OUTSIDE_FUNCTION_OR_METHOD
index: 152
comment: No parameters.
script: |
class C {
var (a, b) = (0, 1);
}
DefaultInSwitchExpression:
parameters: none
problemMessage: A switch expression may not use the `default` keyword.
correctionMessage: Try replacing `default` with `_`.
analyzerCode: ParserErrorCode.DEFAULT_IN_SWITCH_EXPRESSION
index: 153
comment: No parameters.
script: |
void f(x) => switch (x) {
1 => 'one',
default => 'other'
};
RecordUseCannotBePlacedHere:
parameters: none
problemMessage: "`RecordUse` annotation cannot be placed on this element."
WasmImportOrExportInUserCode:
parameters: none
problemMessage: "Pragmas `wasm:import` and `wasm:export` are for internal use only and cannot be used by user code."
WeakReferenceNotStatic:
parameters: none
problemMessage: "Weak reference pragma can be used on a static method only."
script: |
class A {
@pragma('weak-tearoff-reference')
external T Function()? weakReference12<T>(T Function()? x);
}
WeakReferenceNotOneArgument:
parameters: none
problemMessage: "Weak reference should take one required positional argument."
script: |
@pragma('weak-tearoff-reference')
Function? weakRef1({Function? x}) => x;
WeakReferenceReturnTypeNotNullable:
parameters: none
problemMessage: "Return type of a weak reference should be nullable."
script: |
@pragma('weak-tearoff-reference')
Function weakRef(Function x) => x;
WeakReferenceMismatchReturnAndArgumentTypes:
parameters: none
problemMessage: "Return and argument types of a weak reference should match."
script: |
@pragma('weak-tearoff-reference')
Function? weakRef(void Function() x) => x;
WeakReferenceTargetNotStaticTearoff:
parameters: none
problemMessage: "The target of weak reference should be a tearoff of a static method."
script: |
@pragma('weak-tearoff-reference')
Function? validWeakRef(Function? x) => x;
class B {}
void foo() {
validWeakRef(B.new);
}
WeakReferenceTargetHasParameters:
parameters: none
problemMessage: "The target of weak reference should not take parameters."
script: |
@pragma('weak-tearoff-reference')
Function? validWeakRef(Function? x) => x;
class B {
static int arg1(int x) => 42;
}
void foo() {
validWeakRef(B.arg1);
}
ObsoleteColonForDefaultValue:
parameters: none
problemMessage: "Using a colon as a separator before a default value is no longer supported."
correctionMessage: "Try replacing the colon with an equal sign."
script: |
method({int x: 3}) {}
EqualKeysInMapPattern:
parameters: none
problemMessage: Two keys in a map pattern can't be equal.
correctionMessage: Change or remove the duplicate key.
analyzerCode: EQUAL_KEYS_IN_MAP_PATTERN
script: |
method(o) {
if (o case {1: 'foo', 1: 'bar'}) {}
}
EqualKeysInMapPatternContext:
parameters: none
problemMessage: This is the previous use of the same key.
severity: CONTEXT
PatternMatchingError:
parameters: none
problemMessage: "Pattern matching error"
EmptyMapPattern:
parameters: none
problemMessage: A map pattern must have at least one entry.
correctionMessage: Try replacing it with an object pattern 'Map()'.
analyzerCode: EMPTY_MAP_PATTERN
script: |
method(Map m) => switch (m) {
{} => 0,
_ => 1,
};
PatternVariableAssignmentInsideGuard:
parameters: none
problemMessage: Pattern variables can't be assigned inside the guard of the enclosing guarded pattern.
correctionMessage: Try assigning to a different variable.
analyzerCode: PATTERN_VARIABLE_ASSIGNMENT_INSIDE_GUARD
script: |
method(o) => switch (o) {
int i when (i = 5) > 0 => 0,
_ => -1,
};
JointPatternVariableNotInAll:
parameters:
Name name: undocumented
problemMessage: "The variable '#name' is available in some, but not all cases that share this body."
analyzerCode: INVALID_PATTERN_VARIABLE_IN_SHARED_CASE_SCOPE
script: |
test(x) { switch(x) { case var a: case < 0: case [var a]: return a; default: return null; } }
JointPatternVariableWithLabelDefault:
parameters:
Name name: undocumented
problemMessage: "The variable '#name' is not available because there is a label or 'default' case."
analyzerCode: INVALID_PATTERN_VARIABLE_IN_SHARED_CASE_SCOPE
script: |
test(x) { switch(x) { case var a: default: return a; } }
ScriptTagInPartFile:
parameters: none
problemMessage: "A part file cannot have script tag."
correctionMessage: "Try removing the script tag or the 'part of' directive."
script:
main.dart: |
part 'part.dart';
part.dart: |
#!dart
part of 'main.dart';
NonCovariantTypeParameterInRepresentationType:
parameters: none
problemMessage: "An extension type parameter can't be used non-covariantly in its representation type."
correctionMessage: "Try removing the type parameters from function parameter types and type parameter bounds."
script: |
extension type E<T>(void Function(T) f) {}
CyclicRepresentationDependency:
parameters: none
problemMessage: "An extension type can't depend on itself through its representation type."
script: |
extension type E(E it) {}
ExtensionTypeDeclarationCause:
parameters: none
problemMessage: "The issue arises via this extension type declaration."
severity: CONTEXT
InvalidExtensionTypeSuperInterface:
parameters:
Type type: undocumented
Type type2: undocumented
Name name: undocumented
problemMessage: "The implemented interface '#type' must be a supertype of the representation type '#type2' of extension type '#name'."
correctionMessage: "Try changing the interface type to a supertype of '#type2' or the representation type to a subtype of '#type'."
script: |
extension type E(num n) implements int {}
InvalidExtensionTypeSuperExtensionType:
parameters:
Type type: undocumented
Name name: undocumented
Type type2: undocumented
Type type3: undocumented
problemMessage: "The representation type '#type' of extension type '#name' must be either a subtype of the representation type '#type2' of the implemented extension type '#type3' or a subtype of '#type3' itself."
correctionMessage: "Try changing the representation type to a subtype of '#type2'."
script: |
extension type E1(int i) {}
extension type E2(num n) implements E1 {}
MissingPrimaryConstructor:
parameters: none
problemMessage: "An extension type declaration must have a primary constructor declaration."
correctionMessage: "Try adding a primary constructor to the extension type declaration."
index: 162
analyzerCode: ParserErrorCode.MISSING_PRIMARY_CONSTRUCTOR
script: |
extension type E {}
MissingPrimaryConstructorParameters:
parameters: none
problemMessage: "A primary constructor declaration must have formal parameters."
correctionMessage: "Try adding formal parameters after the primary constructor name."
index: 163
analyzerCode: ParserErrorCode.MISSING_PRIMARY_CONSTRUCTOR_PARAMETERS
script: |
extension type E.name {}
ExtensionTypeExtends:
parameters: none
problemMessage: "An extension type declaration can't have an 'extends' clause."
correctionMessage: "Try removing the 'extends' clause or replacing the 'extends' with 'implements'."
index: 164
analyzerCode: ParserErrorCode.EXTENSION_TYPE_EXTENDS
script: |
extension type F(int i) {}
extension type E(int i) extends F {}
ExtensionTypeWith:
parameters: none
problemMessage: "An extension type declaration can't have a 'with' clause."
correctionMessage: "Try removing the 'with' clause or replacing the 'with' with 'implements'."
index: 165
analyzerCode: ParserErrorCode.EXTENSION_TYPE_WITH
script: |
extension type F(int i) {}
extension type E(int i) with F {}
LocalVariableUsedBeforeDeclared:
parameters:
Name name: undocumented
problemMessage: "Local variable '#name' can't be referenced before it is declared."
analyzerCode: REFERENCED_BEFORE_DECLARATION
script: |
foo(dynamic x, dynamic y) { y = x; dynamic x; }
LocalVariableUsedBeforeDeclaredContext:
parameters:
Name name: undocumented
problemMessage: "This is the declaration of the variable '#name'."
severity: CONTEXT
ImplementNonExtensionTypeAndExtensionTypeMember:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "The extension type '#name' can't inherit the member '#name2' as both an extension type member and a non-extension type member."
correctionMessage: "Try declaring a member '#name2' in '#name' to resolve the conflict."
script: |
class Class {
void method() {}
}
extension type ExtensionType(Class c) {
void method() {}
}
extension type ExtensionType1(Class c) implements Class, ExtensionType {}
ExtensionTypeMemberContext:
parameters: none
problemMessage: "This is the inherited extension type member."
severity: CONTEXT
ExtensionTypeMemberOneOfContext:
parameters: none
problemMessage: "This is one of the inherited extension type members."
severity: CONTEXT
NonExtensionTypeMemberContext:
parameters: none
problemMessage: "This is the inherited non-extension type member."
severity: CONTEXT
NonExtensionTypeMemberOneOfContext:
parameters: none
problemMessage: "This is one of the inherited non-extension type members."
severity: CONTEXT
ImplementMultipleExtensionTypeMembers:
parameters:
Name name: undocumented
Name name2: undocumented
problemMessage: "The extension type '#name' can't inherit the member '#name2' from more than one extension type."
correctionMessage: "Try declaring a member '#name2' in '#name' to resolve the conflict."
script: |
extension type ExtensionType1(int i) {
void method() {}
}
extension type ExtensionType2(int i) {
void method() {}
}
extension type ExtensionType3(int i) implements ExtensionType1, ExtensionType2 {}
RepresentationFieldModifier:
parameters: none
problemMessage: "Representation fields can't have modifiers."
script: |
extension type E(final int foo) {}
analyzerCode: REPRESENTATION_FIELD_MODIFIER
ExpectedRepresentationType:
parameters: none
problemMessage: "Expected a representation type."
script: |
extension type E(var foo) {}
analyzerCode: EXPECTED_REPRESENTATION_TYPE
ExpectedRepresentationField:
parameters: none
problemMessage: "Expected a representation field."
script: |
extension type E() {}
analyzerCode: EXPECTED_REPRESENTATION_FIELD
MultipleRepresentationFields:
parameters: none
problemMessage: "Each extension type should have exactly one representation field."
script: |
extension type E(int foo, String bar) {}
analyzerCode: MULTIPLE_REPRESENTATION_FIELDS
ExtensionTypeConstructorWithSuperFormalParameter:
parameters: none
problemMessage: "Extension type constructors can't declare super formal parameters."
script: |
extension type A(int foo) { A.named(this.foo, super.bar); }
analyzerCode: EXTENSION_TYPE_CONSTRUCTOR_WITH_SUPER_FORMAL_PARAMETER
ExtensionTypePrimaryConstructorWithInitializingFormal:
parameters: none
problemMessage: "Primary constructors in extension types can't use initializing formals."
correctionMessage: "Try removing `this.` from the formal parameter."
script: |
extension type A(int this.foo) { }
ExtensionTypePrimaryConstructorFunctionFormalParameterSyntax:
parameters: none
problemMessage: "Primary constructors in extension types can't use function formal parameter syntax."
correctionMessage: "Try rewriting with an explicit function type, like `int Function() f`."
script: |
extension type A(int foo()) { }
ExtensionTypeRepresentationTypeBottom:
parameters: none
problemMessage: "The representation type can't be a bottom type."
script: |
extension type E1(Never foo) {}
analyzerCode: EXTENSION_TYPE_REPRESENTATION_TYPE_BOTTOM
RepresentationFieldTrailingComma:
parameters: none
problemMessage: "The representation field can't have a trailing comma."
script: |
extension type E(int foo,) {}
analyzerCode: REPRESENTATION_FIELD_TRAILING_COMMA
WrongTypeParameterVarianceInSuperinterface:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "'#name' can't be used contravariantly or invariantly in '#type'."
script: |
extension type E<X>(List<Function(Object?)> foo) implements List<Function(X)> {}
analyzerCode: WRONG_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE
AwaitOfExtensionTypeNotFuture:
parameters: none
problemMessage: "The 'await' expression can't be used for an expression with an extension type that is not a subtype of 'Future'."
script: |
extension type E(num foo) { test(E e) async { await e; } }
analyzerCode: AWAIT_OF_EXTENSION_TYPE_NOT_FUTURE
NamedParametersInExtensionTypeDeclaration:
parameters: none
problemMessage: "Extension type declarations can't have named parameters."
script: |
extension type E(int foo, {dynamic bar}) {}
OptionalParametersInExtensionTypeDeclaration:
parameters: none
problemMessage: "Extension type declarations can't have optional parameters."
script: |
extension type E(int foo, [dynamic bar]) {}
ClassImplementsDeferredClass:
parameters: none
problemMessage: "Classes and mixins can't implement deferred classes."
correctionMessage: Try specifying a different interface, removing the class from the list, or changing the import to not be deferred.
analyzerCode: IMPLEMENTS_DEFERRED_CLASS
script:
main.dart: |
import 'lib.dart' deferred as d;
class B implements d.A {}
lib.dart: |
class A {}
MixinDeferredMixin:
parameters: none
problemMessage: "Classes can't mix in deferred mixins."
correctionMessage: Try changing the import to not be deferred.
analyzerCode: MIXIN_DEFERRED_CLASS
script:
main.dart: |
import 'lib.dart' deferred as d;
class B with d.A {}
lib.dart: |
mixin A {}
MixinSuperClassConstraintDeferredClass:
parameters: none
problemMessage: "Deferred classes can't be used as superclass constraints."
correctionMessage: Try changing the import to not be deferred.
analyzerCode: MIXIN_SUPER_CLASS_CONSTRAINT_DEFERRED_CLASS
script:
main.dart: |
import 'lib.dart' deferred as d;
mixin B on d.A {}
lib.dart: |
class A {}
ExtendsDeferredClass:
parameters: none
problemMessage: "Classes can't extend deferred classes."
correctionMessage: Try specifying a different superclass, or removing the extends clause.
analyzerCode: EXTENDS_DEFERRED_CLASS
script:
main.dart: |
import 'lib.dart' deferred as d;
class B extends d.A {}
lib.dart: |
class A {}
ExtensionTypeImplementsDeferred:
parameters: none
problemMessage: "Extension types can't implement deferred types."
correctionMessage: Try specifying a different type, removing the type from the list, or changing the import to not be deferred.
analyzerCode: IMPLEMENTS_DEFERRED_CLASS
script:
main.dart: |
import 'lib.dart' deferred as d;
extension type ET(d.A id) implements d.A {}
lib.dart: |
class A {}
exampleAllowOtherCodes: true
RecordUsedAsCallable:
parameters: none
problemMessage: "The 'call' property on the record type isn't directly callable but could be invoked by `.call(...)`"
script: |
test(({dynamic call}) r) => r(0);
ExperimentExpiredEnabled:
parameters:
Name name: undocumented
problemMessage: "The experiment '#name' has expired and can't be enabled."
ExperimentExpiredDisabled:
parameters:
Name name: undocumented
problemMessage: "The experiment '#name' has expired and can't be disabled."
DartFfiLibraryInDart2Wasm:
parameters: none
problemMessage: "'dart:ffi' can't be imported when compiling to Wasm."
UnexpectedSuperParametersInGenerativeConstructors:
parameters: none
problemMessage: "Super parameters can only be used in non-redirecting generative constructors."
analyzerCode: INVALID_SUPER_FORMAL_PARAMETER_LOCATION
script: |
class A { A(); A.named(super.x) : this(); }
MissingPositionalSuperConstructorParameter:
parameters: none
problemMessage: "The super constructor has no corresponding positional parameter."
analyzerCode: SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_POSITIONAL
script: |
class A { A(); } class B { B(super.foo); }
MissingNamedSuperConstructorParameter:
parameters: none
problemMessage: "The super constructor has no corresponding named parameter."
analyzerCode: SUPER_FORMAL_PARAMETER_WITHOUT_ASSOCIATED_NAMED
script: |
class A { A(); } class B { B({super.foo}); }
ImplicitSuperInitializerMissingArguments:
parameters:
Name name: undocumented
problemMessage: "The implicitly called unnamed constructor from '#name' has required parameters."
correctionMessage: "Try adding an explicit super initializer with the required arguments."
analyzerCode: IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS
script: |
class A { A(int foo); } class B extends A { B(); }
DotShorthandsConstructorInvocationWithTypeArguments:
parameters: none
problemMessage: "A dot shorthand constructor invocation can't have type arguments."
correctionMessage: "Try adding the class name and type arguments explicitly before the constructor name."
experiments: dot-shorthands
script: |
class C<X> {
C.foo();
}
void main() {
C c = .foo<int>();
}
DotShorthandsInvalidContext:
parameters:
Name name: undocumented
problemMessage: "No type was provided to find the dot shorthand '#name'."
experiments: dot-shorthands
script: |
void main() {
var x = .one;
}
DotShorthandsUndefinedGetter:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The static getter or field '#name' isn't defined for the type '#type'."
correctionMessage: "Try correcting the name to the name of an existing static getter or field, or defining a getter or field named '#name'."
experiments: dot-shorthands
script: |
class C {
C get foo => C();
}
void main() {
C c = .foo;
}
DotShorthandsUndefinedInvocation:
parameters:
Name name: undocumented
Type type: undocumented
problemMessage: "The static method or constructor '#name' isn't defined for the type '#type'."
correctionMessage: "Try correcting the name to the name of an existing static method or constructor, or defining a static method or constructor named '#name'."
experiments: dot-shorthands
script: |
class C {
C foo() => C();
}
void main() {
C c = .foo();
}
ExpressionEvaluationKnownVariableUnavailable:
parameters:
Name name: undocumented
problemMessage: "The variable '#name' is unavailable in this expression evaluation."