mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 12:14:36 +00:00
[analyzer] Refactor visitMethodInvocation in the const evaluator.
Change-Id: I9ae6c17967c98770ed06dead200c8bd87ae7f2a9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309829 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Kallen Tu <kallentu@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
4650178857
commit
c86af3c39b
|
@ -9,7 +9,7 @@ String method() => 'foo';
|
|||
|
||||
const String string0 =
|
||||
/*cfe|dart2js.error: Method invocation is not a constant expression.*/
|
||||
method();
|
||||
/*analyzer.error: CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION*/ method();
|
||||
|
||||
main() {
|
||||
print(string0);
|
||||
|
|
|
@ -384,6 +384,8 @@ CompileTimeErrorCode.CONST_EVAL_EXTENSION_METHOD:
|
|||
status: needsEvaluation
|
||||
CompileTimeErrorCode.CONST_EVAL_FOR_ELEMENT:
|
||||
status: needsEvaluation
|
||||
CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION:
|
||||
status: needsEvaluation
|
||||
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION:
|
||||
status: noFix
|
||||
CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE:
|
||||
|
|
|
@ -445,6 +445,19 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
|
|||
var initializer = node.initializer;
|
||||
if (initializer != null && (node.isConst || node.isFinal)) {
|
||||
var element = node.declaredElement as VariableElementImpl;
|
||||
if (element is FieldElement && !element.isStatic) {
|
||||
var enclosingElement = element.enclosingElement2;
|
||||
if (enclosingElement is ClassElementImpl &&
|
||||
!enclosingElement.hasGenerativeConstConstructor) {
|
||||
// TODO(kallentu): Evaluate if we need to do this check for inline
|
||||
// classes.
|
||||
//
|
||||
// We report errors in the class fields only if there's a generative
|
||||
// const constructor in the class.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var result = element.evaluationResult;
|
||||
if (result == null) {
|
||||
// Variables marked "const" should have had their values computed by
|
||||
|
@ -553,6 +566,8 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
|
|||
ErrorCode dataErrorCode = data.errorCode;
|
||||
if (identical(dataErrorCode,
|
||||
CompileTimeErrorCode.CONST_EVAL_EXTENSION_METHOD) ||
|
||||
identical(dataErrorCode,
|
||||
CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION) ||
|
||||
identical(dataErrorCode,
|
||||
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION) ||
|
||||
identical(
|
||||
|
@ -1361,12 +1376,11 @@ extension on Expression {
|
|||
var container = declarationListParent.parent;
|
||||
if (container is ClassDeclaration) {
|
||||
var enclosingClass = container.declaredElement;
|
||||
if (enclosingClass != null) {
|
||||
if (enclosingClass is ClassElementImpl) {
|
||||
// A field initializer of a class with at least one generative
|
||||
// const constructor does not constitute a constant context, but
|
||||
// must be a constant expression.
|
||||
return enclosingClass.constructors
|
||||
.any((c) => c.isConst && !c.isFactory);
|
||||
return enclosingClass.hasGenerativeConstConstructor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -956,7 +956,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
|
|||
}
|
||||
|
||||
@override
|
||||
Constant? visitMethodInvocation(MethodInvocation node) {
|
||||
Constant visitMethodInvocation(MethodInvocation node) {
|
||||
var element = node.methodName.staticElement;
|
||||
if (element is FunctionElement) {
|
||||
if (element.name == "identical") {
|
||||
|
@ -966,14 +966,14 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
|
|||
if (enclosingElement is CompilationUnitElement) {
|
||||
LibraryElement library = enclosingElement.library;
|
||||
if (library.isDartCore) {
|
||||
var leftConstant = arguments[0].accept(this);
|
||||
var rightConstant = arguments[1].accept(this);
|
||||
// TODO(kallentu): Remove unwrapping when isIdentical handles
|
||||
// Constant.
|
||||
var leftArgument =
|
||||
leftConstant is DartObjectImpl ? leftConstant : null;
|
||||
var rightArgument =
|
||||
rightConstant is DartObjectImpl ? rightConstant : null;
|
||||
var leftArgument = _getConstant(arguments[0]);
|
||||
if (leftArgument is! DartObjectImpl) {
|
||||
return leftArgument;
|
||||
}
|
||||
var rightArgument = _getConstant(arguments[1]);
|
||||
if (rightArgument is! DartObjectImpl) {
|
||||
return rightArgument;
|
||||
}
|
||||
return _dartObjectComputer.isIdentical(
|
||||
node, leftArgument, rightArgument);
|
||||
}
|
||||
|
@ -981,10 +981,11 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
|
|||
}
|
||||
}
|
||||
}
|
||||
// TODO(https://github.com/dart-lang/sdk/issues/47061): Use a specific
|
||||
// error code.
|
||||
_error(node, null);
|
||||
return null;
|
||||
// TODO(kallentu): Don't report error here.
|
||||
_errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION, node);
|
||||
return InvalidConstant(
|
||||
node, CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1944,16 +1945,15 @@ class DartObjectComputer {
|
|||
return null;
|
||||
}
|
||||
|
||||
DartObjectImpl? isIdentical(Expression node, DartObjectImpl? leftOperand,
|
||||
DartObjectImpl? rightOperand) {
|
||||
if (leftOperand != null && rightOperand != null) {
|
||||
try {
|
||||
return leftOperand.isIdentical2(_typeSystem, rightOperand);
|
||||
} on EvaluationException catch (exception) {
|
||||
_errorReporter.reportErrorForNode(exception.errorCode, node);
|
||||
}
|
||||
Constant isIdentical(Expression node, DartObjectImpl leftOperand,
|
||||
DartObjectImpl rightOperand) {
|
||||
try {
|
||||
return leftOperand.isIdentical2(_typeSystem, rightOperand);
|
||||
} on EvaluationException catch (exception) {
|
||||
// TODO(kallentu): Don't report error here.
|
||||
_errorReporter.reportErrorForNode(exception.errorCode, node);
|
||||
return InvalidConstant(node, exception.errorCode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
DartObjectImpl? lazyAnd(BinaryExpression node, DartObjectImpl? leftOperand,
|
||||
|
|
|
@ -632,6 +632,10 @@ class ClassElementImpl extends ClassOrMixinElementImpl implements ClassElement {
|
|||
super.fields = fields;
|
||||
}
|
||||
|
||||
bool get hasGenerativeConstConstructor {
|
||||
return constructors.any((c) => !c.isFactory && c.isConst);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get hasNonFinalField {
|
||||
final classesToVisit = <InterfaceElement>[];
|
||||
|
|
|
@ -809,6 +809,12 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
|
|||
"Try replacing the 'for' element with a spread, or removing 'const'.",
|
||||
);
|
||||
|
||||
static const CompileTimeErrorCode CONST_EVAL_METHOD_INVOCATION =
|
||||
CompileTimeErrorCode(
|
||||
'CONST_EVAL_METHOD_INVOCATION',
|
||||
"Methods can't be invoked in constant expressions.",
|
||||
);
|
||||
|
||||
/// 16.12.2 Const: It is a compile-time error if evaluation of a constant
|
||||
/// object results in an uncaught exception being thrown.
|
||||
static const CompileTimeErrorCode CONST_EVAL_THROWS_EXCEPTION =
|
||||
|
|
|
@ -111,6 +111,7 @@ const List<ErrorCode> errorCodeValues = [
|
|||
CompileTimeErrorCode.CONST_DEFERRED_CLASS,
|
||||
CompileTimeErrorCode.CONST_EVAL_EXTENSION_METHOD,
|
||||
CompileTimeErrorCode.CONST_EVAL_FOR_ELEMENT,
|
||||
CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION,
|
||||
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
|
||||
CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE,
|
||||
CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL,
|
||||
|
|
|
@ -905,6 +905,7 @@ class _ConstantAnalysisErrorListener extends AnalysisErrorListener {
|
|||
case CompileTimeErrorCode
|
||||
.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST:
|
||||
case CompileTimeErrorCode.CONST_EVAL_EXTENSION_METHOD:
|
||||
case CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION:
|
||||
case CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL:
|
||||
case CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_INT:
|
||||
case CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING:
|
||||
|
|
|
@ -2340,8 +2340,9 @@ CompileTimeErrorCode:
|
|||
initialized to a non-constant value:
|
||||
|
||||
```dart
|
||||
String x = '3';
|
||||
class C {
|
||||
final String s = 3.toString();
|
||||
final String s = x;
|
||||
[!const!] C();
|
||||
}
|
||||
```
|
||||
|
@ -2362,8 +2363,9 @@ CompileTimeErrorCode:
|
|||
keyword `const` from the constructor:
|
||||
|
||||
```dart
|
||||
String x = '3';
|
||||
class C {
|
||||
final String s = 3.toString();
|
||||
final String s = x;
|
||||
C();
|
||||
}
|
||||
```
|
||||
|
@ -2573,6 +2575,8 @@ CompileTimeErrorCode:
|
|||
CONST_EVAL_FOR_ELEMENT:
|
||||
problemMessage: "Constant expressions don't support 'for' elements."
|
||||
correctionMessage: "Try replacing the 'for' element with a spread, or removing 'const'."
|
||||
CONST_EVAL_METHOD_INVOCATION:
|
||||
problemMessage: "Methods can't be invoked in constant expressions."
|
||||
CONST_EVAL_THROWS_EXCEPTION:
|
||||
problemMessage: Evaluation of this constant expression throws an exception.
|
||||
comment: |-
|
||||
|
|
|
@ -1351,6 +1351,17 @@ const x = <int>[...a];
|
|||
_assertNull('x');
|
||||
}
|
||||
|
||||
test_visitMethodInvocation_notIdentical() async {
|
||||
await assertErrorsInCode(r'''
|
||||
int f() {
|
||||
return 3;
|
||||
}
|
||||
const a = f();
|
||||
''', [
|
||||
error(CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION, 34, 3),
|
||||
]);
|
||||
}
|
||||
|
||||
test_visitNamedType_typeLiteral_typeParameter_nested() async {
|
||||
await assertErrorsInCode(r'''
|
||||
void f<T>(Object? x) {
|
||||
|
|
|
@ -1422,8 +1422,7 @@ class A {
|
|||
const a = 0;
|
||||
const b = A.foo(a);
|
||||
''', [
|
||||
error(CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE, 66,
|
||||
8),
|
||||
error(CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION, 66, 8),
|
||||
]);
|
||||
|
||||
var node = findNode.singleMethodInvocation;
|
||||
|
@ -1457,8 +1456,7 @@ MethodInvocation
|
|||
const a = 0;
|
||||
const b = 'abc'.codeUnitAt(a);
|
||||
''', [
|
||||
error(CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE, 23,
|
||||
19),
|
||||
error(CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION, 23, 19),
|
||||
]);
|
||||
|
||||
var node = findNode.singleMethodInvocation;
|
||||
|
|
|
@ -42,6 +42,7 @@ int f() {
|
|||
return 3;
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION, 26, 3),
|
||||
error(
|
||||
CompileTimeErrorCode
|
||||
.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST,
|
||||
|
@ -78,6 +79,24 @@ int f() {
|
|||
''');
|
||||
}
|
||||
|
||||
// test_enum_factoryConstructor() async {
|
||||
// await assertErrorsInCode(r'''
|
||||
// enum E {
|
||||
// v;
|
||||
// final int i = f();
|
||||
// const factory E();
|
||||
// }
|
||||
// int f() => 0;
|
||||
// ''', [
|
||||
// error(CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION, 30, 3),
|
||||
// error(
|
||||
// CompileTimeErrorCode
|
||||
// .CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST,
|
||||
// 37,
|
||||
// 5),
|
||||
// ]);
|
||||
// }
|
||||
|
||||
test_enum_instanceField() async {
|
||||
await assertErrorsInCode(r'''
|
||||
enum E {
|
||||
|
@ -87,6 +106,7 @@ enum E {
|
|||
}
|
||||
int f() => 0;
|
||||
''', [
|
||||
error(CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION, 30, 3),
|
||||
error(
|
||||
CompileTimeErrorCode
|
||||
.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST,
|
||||
|
@ -103,6 +123,22 @@ enum E {
|
|||
const E();
|
||||
}
|
||||
int f() => 0;
|
||||
''');
|
||||
}
|
||||
|
||||
test_mixinClass_factory() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
int e = 3;
|
||||
mixin class MixinClassFactory {
|
||||
final int foo = e;
|
||||
const factory MixinClassFactory.x() = A;
|
||||
}
|
||||
|
||||
mixin class A implements MixinClassFactory {
|
||||
@override
|
||||
final int foo = 0;
|
||||
const A();
|
||||
}
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (c) 2023, 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.
|
||||
|
||||
import 'package:analyzer/src/error/codes.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../dart/resolution/context_collection_resolution.dart';
|
||||
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(ConstEvalMethodInvocationTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class ConstEvalMethodInvocationTest extends PubPackageResolutionTest {
|
||||
test_function() async {
|
||||
await assertErrorsInCode('''
|
||||
int f() {
|
||||
return 3;
|
||||
}
|
||||
const a = f();
|
||||
''', [
|
||||
error(CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION, 34, 3),
|
||||
]);
|
||||
}
|
||||
|
||||
test_identical() async {
|
||||
await assertNoErrorsInCode('''
|
||||
const a = identical(1, 1);
|
||||
''');
|
||||
}
|
||||
}
|
|
@ -105,6 +105,7 @@ import 'const_constructor_with_non_final_field_test.dart'
|
|||
import 'const_deferred_class_test.dart' as const_deferred_class;
|
||||
import 'const_eval_extension_method_test.dart' as const_eval_extension_method;
|
||||
import 'const_eval_for_element_test.dart' as const_eval_for_element;
|
||||
import 'const_eval_method_invocation_test.dart' as const_eval_method_invocation;
|
||||
import 'const_eval_throws_exception_test.dart' as const_eval_throws_exception;
|
||||
import 'const_eval_throws_idbze_test.dart' as const_eval_throws_idbze;
|
||||
import 'const_eval_type_bool_int_test.dart' as const_eval_type_bool_int;
|
||||
|
@ -954,6 +955,7 @@ main() {
|
|||
const_deferred_class.main();
|
||||
const_eval_extension_method.main();
|
||||
const_eval_for_element.main();
|
||||
const_eval_method_invocation.main();
|
||||
const_eval_throws_exception.main();
|
||||
const_eval_throws_idbze.main();
|
||||
const_eval_type_bool_int.main();
|
||||
|
|
|
@ -2849,8 +2849,9 @@ The following code produces this diagnostic because the field `s` is
|
|||
initialized to a non-constant value:
|
||||
|
||||
{% prettify dart tag=pre+code %}
|
||||
String x = '3';
|
||||
class C {
|
||||
final String s = 3.toString();
|
||||
final String s = x;
|
||||
[!const!] C();
|
||||
}
|
||||
{% endprettify %}
|
||||
|
@ -2871,8 +2872,9 @@ If the field can't be initialized to a constant value, then remove the
|
|||
keyword `const` from the constructor:
|
||||
|
||||
{% prettify dart tag=pre+code %}
|
||||
String x = '3';
|
||||
class C {
|
||||
final String s = 3.toString();
|
||||
final String s = x;
|
||||
C();
|
||||
}
|
||||
{% endprettify %}
|
||||
|
|
|
@ -16,9 +16,7 @@ const m2 = const {
|
|||
const m3 = const {
|
||||
"foo".codeUnitAt(0): 42
|
||||
//^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
//^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.NON_CONSTANT_MAP_KEY
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// ^
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@ void main() {
|
|||
const c5 = constField;
|
||||
const c6 = method();
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
const c7 = new Class();
|
||||
// ^^^^^^^^^^^
|
||||
|
|
|
@ -9,13 +9,13 @@ class C {
|
|||
}
|
||||
|
||||
const
|
||||
// [error line 11, column 1, length 5]
|
||||
// [error column 1, length 5]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
|
||||
// [cfe] Can't have modifier 'const' here.
|
||||
t() => null;
|
||||
|
||||
const
|
||||
// [error line 17, column 1, length 5]
|
||||
// [error column 1, length 5]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
|
||||
// [cfe] Can't have modifier 'const' here.
|
||||
get v => null;
|
||||
|
@ -24,12 +24,11 @@ main() {
|
|||
const
|
||||
dynamic x = t();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
const y = const C();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_WITH_NON_CONST
|
||||
// ^
|
||||
// [cfe] Cannot invoke a non-'const' factory where a const expression is expected.
|
||||
|
|
|
@ -6,7 +6,8 @@ import "package:expect/expect.dart";
|
|||
|
||||
class A {
|
||||
final int i = f();
|
||||
// ^
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
final int j = 1;
|
||||
const A();
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int fn() {
|
||||
int x = 1;
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn() {
|
||||
int x = 0;
|
||||
assert(x == 0, "fail");
|
||||
|
@ -19,7 +19,7 @@ int fn() {
|
|||
|
||||
const var2 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn2() {
|
||||
int x = 0;
|
||||
assert(() {
|
||||
|
|
|
@ -12,25 +12,25 @@ void blockTest() {
|
|||
int x() => 1;
|
||||
const i = x();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
Expect.equals(i, 1);
|
||||
{
|
||||
int x() => 2;
|
||||
const y = x();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
Expect.equals(y, 2);
|
||||
{
|
||||
int x() => 3;
|
||||
const y = x();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
Expect.equals(y, 3);
|
||||
}
|
||||
}
|
||||
const z = x();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
Expect.equals(z, 1);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ void blockTest1() {
|
|||
|
||||
const i = x();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
Expect.equals(i, 3);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import "package:expect/expect.dart";
|
|||
var varVariable = 1;
|
||||
const var1 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int fn() {
|
||||
return varVariable;
|
||||
|
@ -20,7 +20,7 @@ int fn() {
|
|||
final finalVariable = 1;
|
||||
const var2 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int fn2() {
|
||||
return finalVariable;
|
||||
|
@ -28,7 +28,7 @@ int fn2() {
|
|||
|
||||
const var3 = fn3();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn3() {
|
||||
int innerFn() {
|
||||
return x;
|
||||
|
@ -44,7 +44,7 @@ int fn3() {
|
|||
|
||||
const var4 = fn4();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn4() {
|
||||
var a = () {
|
||||
return x;
|
||||
|
@ -59,7 +59,7 @@ int fn4() {
|
|||
|
||||
const var5 = fn5(1);
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
fn5(a) {
|
||||
var a = () => a;
|
||||
// ^
|
||||
|
@ -75,7 +75,6 @@ void fn6() {
|
|||
int a() => x;
|
||||
const z = a();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = foo();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int foo() {
|
||||
var f = () {
|
||||
int count = 0;
|
||||
|
@ -43,7 +43,7 @@ int foo() {
|
|||
|
||||
const var2 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn() {
|
||||
return (() => 0)();
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ int fn() {
|
|||
const y = 1;
|
||||
const var3 = fn3();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn3() {
|
||||
int y = 2;
|
||||
return y;
|
||||
|
@ -59,7 +59,7 @@ int fn3() {
|
|||
|
||||
const var4 = fn4();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn4() {
|
||||
var x = 0;
|
||||
int innerFn() {
|
||||
|
@ -71,7 +71,7 @@ int fn4() {
|
|||
|
||||
const var5 = fn5(3);
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn5(int a) {
|
||||
int recurse(int b) {
|
||||
if (b == 1) return 1;
|
||||
|
@ -84,7 +84,7 @@ int fn5(int a) {
|
|||
|
||||
const var6 = fn6(4);
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn6(int a) {
|
||||
int recurse() {
|
||||
a--;
|
||||
|
|
|
@ -16,8 +16,8 @@ class Simple {
|
|||
const Simple(this.name) {
|
||||
//^
|
||||
// [cfe] A const constructor can't have a body.
|
||||
// ^
|
||||
// [analyzer] SYNTACTIC_ERROR.CONST_CONSTRUCTOR_WITH_BODY
|
||||
// ^
|
||||
// [analyzer] SYNTACTIC_ERROR.CONST_CONSTRUCTOR_WITH_BODY
|
||||
assert(this.name == printString);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class A {
|
|||
|
||||
const var3 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
A fn() => A();
|
||||
|
||||
void main() {
|
||||
|
|
|
@ -6,62 +6,62 @@
|
|||
|
||||
const binary = binaryFn(2, 1);
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
int binaryFn(int a, int b) => a - b;
|
||||
|
||||
const optional = optionalFn(2);
|
||||
// ^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
const optional1 = optionalFn(2, 1);
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
int optionalFn(int c, [int d = 0]) => c + d;
|
||||
|
||||
const named = namedFn(2, f: 2);
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
const named1 = namedFn(2);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
int namedFn(int e, {int f = 3}) => e + f;
|
||||
|
||||
const type = typeFn(6);
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
T typeFn<T>(T x) => x;
|
||||
|
||||
const str = stringFn("str");
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
String stringFn(String s) => s + "ing";
|
||||
|
||||
const eq = equalFn(2, 2);
|
||||
// ^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
bool equalFn(int a, int b) => a == b;
|
||||
|
||||
const neg = unary(2);
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
int unary(int a) => -a;
|
||||
|
||||
const boolean = boolFn(true, false);
|
||||
// ^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
bool boolFn(bool a, bool b) => a || b;
|
||||
|
||||
const doub = doubleFn(2.2, 2);
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
double doubleFn(double a, double b) => a * b;
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn() {
|
||||
int x = 0;
|
||||
do {
|
||||
|
@ -24,7 +24,7 @@ int fn() {
|
|||
|
||||
const var2 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int fn2() {
|
||||
int x = 0;
|
||||
|
@ -36,7 +36,7 @@ int fn2() {
|
|||
|
||||
const var3 = fn3();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int fn3() {
|
||||
dynamic x = 0;
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn() {
|
||||
int x = 0;
|
||||
do {
|
||||
|
@ -21,10 +21,10 @@ int fn() {
|
|||
|
||||
const var2 = fn2(2);
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var3 = fn2(10);
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn2(int a) {
|
||||
int x = 0, b = 0;
|
||||
do {
|
||||
|
@ -37,7 +37,7 @@ int fn2(int a) {
|
|||
|
||||
const var4 = fn3();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn3() {
|
||||
int x = 0, b = 0;
|
||||
do {
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn() {
|
||||
int val = 0;
|
||||
for (; val;) {
|
||||
|
@ -24,7 +24,7 @@ int fn() {
|
|||
|
||||
const var2 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int fn2() {
|
||||
int val = 0;
|
||||
|
@ -36,7 +36,7 @@ int fn2() {
|
|||
|
||||
const var3 = fn3();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int fn3() {
|
||||
dynamic val = 0;
|
||||
|
|
|
@ -10,10 +10,10 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = fn(2);
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var2 = fn(3);
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn(int a) {
|
||||
int b = a;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
@ -24,10 +24,10 @@ int fn(int a) {
|
|||
|
||||
const var3 = fn1(2);
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var4 = fn1(3);
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn1(int a) {
|
||||
int b = a;
|
||||
for (int i = 0;; i++) {
|
||||
|
@ -38,7 +38,7 @@ int fn1(int a) {
|
|||
|
||||
const var5 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn2() {
|
||||
for (int i = 0, j = 2;; i += 2, j += 1) {
|
||||
if (i + j > 10) {
|
||||
|
@ -49,7 +49,7 @@ int fn2() {
|
|||
|
||||
const var6 = fnContinue();
|
||||
// ^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fnContinue() {
|
||||
int a = 0;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
|
@ -61,10 +61,10 @@ int fnContinue() {
|
|||
|
||||
const var7 = fnBreak(2);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var8 = fnBreak(3);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fnBreak(int a) {
|
||||
int b = a;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
@ -76,7 +76,7 @@ int fnBreak(int a) {
|
|||
|
||||
const var9 = fnNestedFor();
|
||||
// ^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fnNestedFor() {
|
||||
int a = 0;
|
||||
for (;;) {
|
||||
|
@ -89,7 +89,7 @@ int fnNestedFor() {
|
|||
|
||||
const var10 = fnBreakLabel();
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fnBreakLabel() {
|
||||
foo:
|
||||
for (;;) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn() {
|
||||
int val = 0;
|
||||
if (val) {
|
||||
|
@ -24,7 +24,7 @@ int fn() {
|
|||
|
||||
const var2 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int fn2() {
|
||||
int val = 0;
|
||||
|
@ -36,7 +36,7 @@ int fn2() {
|
|||
|
||||
const var3 = fn3();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int fn3() {
|
||||
dynamic val = 0;
|
||||
|
|
|
@ -10,13 +10,13 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = ifTest(1);
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var2 = ifTest(2);
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var3 = ifTest(3);
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int ifTest(int a) {
|
||||
if (a == 1) {
|
||||
return 100;
|
||||
|
@ -30,10 +30,10 @@ int ifTest(int a) {
|
|||
const one = 1;
|
||||
const var4 = ifTest2(1);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var5 = ifTest2(2);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int ifTest2(int a) {
|
||||
if (a == one) {
|
||||
return 100;
|
||||
|
@ -44,13 +44,13 @@ int ifTest2(int a) {
|
|||
|
||||
const var6 = ifTest3(1);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var6_1 = ifTest3(2);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var6_2 = ifTest3(0);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int ifTest3(int a) {
|
||||
if (a > 0) {
|
||||
if (a == 1) return 100;
|
||||
|
@ -61,7 +61,7 @@ int ifTest3(int a) {
|
|||
|
||||
const var7 = ifTest4(1);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int ifTest4(int a) {
|
||||
int b = a;
|
||||
if (a == 1) {
|
||||
|
@ -78,7 +78,7 @@ int ifTest4(int a) {
|
|||
|
||||
const var8 = ifTest5();
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int ifTest5() {
|
||||
var x = 10;
|
||||
if (true) var x = 20;
|
||||
|
|
|
@ -16,7 +16,7 @@ class A {
|
|||
|
||||
const var1 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn() => const A(1).x;
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_GETTER
|
||||
|
@ -24,7 +24,7 @@ int fn() => const A(1).x;
|
|||
|
||||
const var2 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn2() {
|
||||
var x = const A(1);
|
||||
return x.x;
|
||||
|
|
|
@ -16,12 +16,12 @@ class A {
|
|||
|
||||
const var1 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn() => const A(1).y;
|
||||
|
||||
const var2 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn2() {
|
||||
var x = const A(1);
|
||||
return x.y;
|
||||
|
@ -37,7 +37,7 @@ class B extends A {
|
|||
|
||||
const var4 = fn4();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn4() => const B(1).y;
|
||||
|
||||
class C extends A {
|
||||
|
@ -49,7 +49,7 @@ class C extends A {
|
|||
|
||||
const var5 = fn5();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn5() => const C().y;
|
||||
|
||||
void main() {
|
||||
|
|
|
@ -52,73 +52,73 @@ class G<T> extends F<T, String, num> {
|
|||
|
||||
const var1 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
String fn() => const A().toString();
|
||||
|
||||
const toString1 = const A().toString();
|
||||
// ^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
|
||||
const var2 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
String fn2() => const B().toString();
|
||||
|
||||
const toString2 = const B().toString();
|
||||
// ^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
|
||||
const var3 = fn3();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var4 = fn4();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn3() => const C(0).fn();
|
||||
int fn4() => const C(1).fn();
|
||||
|
||||
const fnVal1 = const C(0).fn();
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const fnVal2 = const C(1).fn();
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
|
||||
const var5 = fn5();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn5() => const D(1).fn();
|
||||
|
||||
const fnVal3 = const D(1).fn();
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
|
||||
const var6 = fn6();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn6() => const E(1).fn();
|
||||
|
||||
const fnVal4 = const E(0).fn();
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
|
||||
const var7 = fn7();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
String fn7() => const F<int, String, num>().fn("string");
|
||||
|
||||
const fnVal5 = const F<int, String, num>().fn("string");
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
|
||||
const var8 = fn8();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
String fn8() => const G<int>().fn("string");
|
||||
|
||||
const fnVal6 = const G<int>().fn("string");
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
|
||||
void main() {
|
||||
Expect.equals(var1, const A().toString());
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const firstException = firstExceptionFn();
|
||||
// ^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int firstExceptionFn() {
|
||||
const List<int> x = [];
|
||||
|
@ -19,7 +19,7 @@ int firstExceptionFn() {
|
|||
|
||||
const lastException = lastExceptionFn();
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int lastExceptionFn() {
|
||||
const List<int> x = [];
|
||||
|
@ -28,7 +28,7 @@ int lastExceptionFn() {
|
|||
|
||||
const singleException = singleExceptionFn();
|
||||
// ^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int singleExceptionFn() {
|
||||
const List<int> x = [];
|
||||
|
@ -37,7 +37,7 @@ int singleExceptionFn() {
|
|||
|
||||
const singleExceptionMulti = singleExceptionMultiFn();
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int singleExceptionMultiFn() {
|
||||
const List<int> x = [1, 2];
|
||||
|
@ -46,7 +46,7 @@ int singleExceptionMultiFn() {
|
|||
|
||||
const invalidProperty = invalidPropertyFn();
|
||||
// ^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int invalidPropertyFn() {
|
||||
const List<int> x = [1, 2];
|
||||
return x.invalidProperty;
|
||||
|
@ -57,7 +57,7 @@ int invalidPropertyFn() {
|
|||
|
||||
const getWithIndexException = getWithIndexExceptionFn();
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int getWithIndexExceptionFn() {
|
||||
const List<int> x = [1];
|
||||
|
@ -66,7 +66,7 @@ int getWithIndexExceptionFn() {
|
|||
|
||||
const getWithIndexException2 = getWithIndexExceptionFn2();
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int getWithIndexExceptionFn2() {
|
||||
const List<int> x = [1];
|
||||
|
@ -75,7 +75,7 @@ int getWithIndexExceptionFn2() {
|
|||
|
||||
const getWithIndexException3 = getWithIndexExceptionFn3();
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int getWithIndexExceptionFn3() {
|
||||
const List<int> x = [1];
|
||||
return x[0.1];
|
||||
|
@ -86,7 +86,7 @@ int getWithIndexExceptionFn3() {
|
|||
|
||||
const constListAddException = constListAddExceptionFn();
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
List<int> constListAddExceptionFn() {
|
||||
const List<int> x = [1, 2];
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const firstVar = firstFn();
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int firstFn() {
|
||||
const List<int> x = [1, 2];
|
||||
return x.first;
|
||||
|
@ -18,7 +18,7 @@ int firstFn() {
|
|||
|
||||
const firstCatchVar = firstCatchFn();
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int firstCatchFn() {
|
||||
try {
|
||||
const List<int> x = [];
|
||||
|
@ -31,7 +31,7 @@ int firstCatchFn() {
|
|||
|
||||
const isEmptyVar = isEmptyFn();
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
bool isEmptyFn() {
|
||||
const List<int> x = [1, 2];
|
||||
return x.isEmpty;
|
||||
|
@ -39,7 +39,7 @@ bool isEmptyFn() {
|
|||
|
||||
const isNotEmptyVar = isNotEmptyFn();
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
bool isNotEmptyFn() {
|
||||
const List<int> x = [1, 2];
|
||||
return x.isNotEmpty;
|
||||
|
@ -47,7 +47,7 @@ bool isNotEmptyFn() {
|
|||
|
||||
const lastVar = lastFn();
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int lastFn() {
|
||||
const List<int> x = [1, 2];
|
||||
return x.last;
|
||||
|
@ -55,7 +55,7 @@ int lastFn() {
|
|||
|
||||
const lastCatchVar = lastCatchFn();
|
||||
// ^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int lastCatchFn() {
|
||||
try {
|
||||
const List<int> x = [];
|
||||
|
@ -68,7 +68,7 @@ int lastCatchFn() {
|
|||
|
||||
const lengthVar = lengthFn();
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int lengthFn() {
|
||||
const List<int> x = [1, 2];
|
||||
return x.length;
|
||||
|
@ -76,7 +76,7 @@ int lengthFn() {
|
|||
|
||||
const singleVar = singleFn();
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int singleFn() {
|
||||
const List<int> x = [1];
|
||||
return x.single;
|
||||
|
@ -84,7 +84,7 @@ int singleFn() {
|
|||
|
||||
const singleCatchVar = singleCatchFn();
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int singleCatchFn() {
|
||||
try {
|
||||
const List<int> x = [];
|
||||
|
@ -97,7 +97,7 @@ int singleCatchFn() {
|
|||
|
||||
const singleCatchVar2 = singleCatchFn2();
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int singleCatchFn2() {
|
||||
try {
|
||||
const List<int> x = [1, 2];
|
||||
|
@ -110,7 +110,7 @@ int singleCatchFn2() {
|
|||
|
||||
const getWithIndexVar = getWithIndexFn();
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int getWithIndexFn() {
|
||||
const List<int> x = [1];
|
||||
return x[0];
|
||||
|
@ -118,7 +118,7 @@ int getWithIndexFn() {
|
|||
|
||||
const rangeErrorCatchVar = rangeErrorCatchFn();
|
||||
// ^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int rangeErrorCatchFn() {
|
||||
try {
|
||||
const List<int> x = [1];
|
||||
|
@ -131,7 +131,7 @@ int rangeErrorCatchFn() {
|
|||
|
||||
const mutableListVar = mutableList();
|
||||
// ^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
List<int> mutableList() {
|
||||
List<int> x = [1, 2];
|
||||
return x;
|
||||
|
@ -139,7 +139,7 @@ List<int> mutableList() {
|
|||
|
||||
const mutableListAddVar = mutableListAdd();
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
List<int> mutableListAdd() {
|
||||
List<int> x = [1, 2];
|
||||
x.add(3);
|
||||
|
|
|
@ -12,7 +12,7 @@ int function1() {
|
|||
int add(int a, int b) => a + b;
|
||||
const value = add(10, 2);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ int function2() {
|
|||
|
||||
const value = addTwo(2);
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ int function3() {
|
|||
int addTwoReturn(int a) => a + constTwo;
|
||||
const value = addTwoReturn(3);
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ int function4() {
|
|||
int addTwo(int a) => a + localTwo;
|
||||
const value = addTwo(20);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ int function5() {
|
|||
T typeFn<T>(T a) => a;
|
||||
const value = typeFn(3);
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ int function6() {
|
|||
int optionalFn([int a = 0]) => a;
|
||||
const value = optionalFn(1);
|
||||
// ^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ int function7() {
|
|||
int namedFn({int a = 0}) => a;
|
||||
const value = namedFn(a: 2);
|
||||
// ^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -74,10 +74,10 @@ int function8() {
|
|||
int add(int a, int b) => a + b;
|
||||
const value = add(1, 1);
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const value1 = add(2, 3);
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
return value + value1;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,26 +10,26 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = fn({'key': 'val'}, 'key');
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
|
||||
const var2 = fn({'key': 2}, 'key');
|
||||
// ^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
|
||||
const var3 = fn({'key': 2}, 'invalid');
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
|
||||
const map = {'key1': 2, 'key2': 3, 'key3': 4};
|
||||
const var4 = fn(map, 'key1');
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var5 = fn(map, 'key2');
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var6 = fn(map, 'key3');
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
|
||||
Object? fn(Map<Object, Object> map, Object key) {
|
||||
return map[key];
|
||||
|
@ -37,7 +37,7 @@ Object? fn(Map<Object, Object> map, Object key) {
|
|||
|
||||
const var7 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int? fn2() {
|
||||
const y = {'key': 2};
|
||||
return y['key'];
|
||||
|
|
|
@ -14,7 +14,7 @@ const dependsOnB = b;
|
|||
// [cfe] Constant evaluation error:
|
||||
const b = fn(4);
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn(int a) {
|
||||
if (a == 1) return dependsOnB;
|
||||
return dependsOnB * fn(a - 1);
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const b = fn(4);
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn(int a) {
|
||||
if (a == 1) return 1;
|
||||
return a * fn(a - 1);
|
||||
|
@ -24,7 +24,7 @@ int localTest() {
|
|||
|
||||
const c = fnLocal(4);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,31 +10,31 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
void fn() {}
|
||||
|
||||
const var2 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
void fn2() {
|
||||
return;
|
||||
}
|
||||
|
||||
const var3 = fn3();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int? fn3() => null;
|
||||
|
||||
const var4 = fn4();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int? fn4() {
|
||||
return null;
|
||||
}
|
||||
|
||||
const var5 = fn5();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [web] Constant evaluation error:
|
||||
int fn5() {
|
||||
try {
|
||||
|
|
|
@ -10,61 +10,61 @@ import "package:expect/expect.dart";
|
|||
|
||||
const binary = binaryFn(2, 1);
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int binaryFn(int a, int b) => a - b;
|
||||
|
||||
const optional = optionalFn(2);
|
||||
// ^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const optional1 = optionalFn(2, 1);
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int optionalFn(int c, [int d = 0]) => c + d;
|
||||
|
||||
const named = namedFn(2, f: 2);
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const named1 = namedFn(2);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int namedFn(int e, {int f = 3}) => e + f;
|
||||
|
||||
const type = typeFn(6);
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
T typeFn<T>(T x) => x;
|
||||
|
||||
const str = stringFn("str");
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
String stringFn(String s) => s + "ing";
|
||||
|
||||
const eq = equalFn(2, 2);
|
||||
// ^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
bool equalFn(int a, int b) => a == b;
|
||||
|
||||
const neg = unary(2);
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int unary(int a) => -a;
|
||||
|
||||
const boolean = boolFn(true, false);
|
||||
// ^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
bool boolFn(bool a, bool b) => a || b;
|
||||
|
||||
const doub = doubleFn(2.2, 2);
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
double doubleFn(double a, double b) => a * b;
|
||||
|
||||
const multi = multiFn(1);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const multi2 = multiFn(2);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int multiFn(int a) => a + 1;
|
||||
|
||||
void main() {
|
||||
|
|
|
@ -22,7 +22,7 @@ const var2 = str[3];
|
|||
|
||||
const var3 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
fn() {
|
||||
String s = "str";
|
||||
|
@ -31,7 +31,7 @@ fn() {
|
|||
|
||||
const var4 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
fn2() {
|
||||
String s = "str";
|
||||
|
@ -40,7 +40,7 @@ fn2() {
|
|||
|
||||
const var5 = fn3();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
fn3() {
|
||||
String s = "str";
|
||||
return str[1.1];
|
||||
|
|
|
@ -15,7 +15,7 @@ const var1 = str[2];
|
|||
|
||||
const var2 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
fn() {
|
||||
String local = "str";
|
||||
return local[0];
|
||||
|
@ -27,7 +27,7 @@ const var3 = "str"[0];
|
|||
|
||||
const var4 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
fn2() {
|
||||
try {
|
||||
var x = str[-1];
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = labelDoesNotExistSwitch(1);
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int labelDoesNotExistSwitch(int x) {
|
||||
switch (x) {
|
||||
labelOtherSwitch:
|
||||
|
|
|
@ -10,10 +10,10 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = basicSwitch(1);
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var2 = basicSwitch(2);
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int basicSwitch(int x) {
|
||||
switch (x) {
|
||||
case 1:
|
||||
|
@ -27,13 +27,13 @@ int basicSwitch(int x) {
|
|||
|
||||
const var3 = multipleCaseSwitch(1);
|
||||
// ^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var4 = multipleCaseSwitch(2);
|
||||
// ^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var5 = multipleCaseSwitch(3);
|
||||
// ^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int multipleCaseSwitch(int x) {
|
||||
switch (x) {
|
||||
case 1:
|
||||
|
@ -47,16 +47,16 @@ int multipleCaseSwitch(int x) {
|
|||
|
||||
const var6 = continueLabelSwitch(1);
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var7 = continueLabelSwitch(2);
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var8 = continueLabelSwitch(3);
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var9 = continueLabelSwitch(4);
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int continueLabelSwitch(int x) {
|
||||
switch (x) {
|
||||
label1:
|
||||
|
|
|
@ -10,11 +10,11 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = finallyThrow(0);
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
const var2 = finallyThrow(1);
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int finallyThrow(int x) {
|
||||
try {
|
||||
|
@ -30,11 +30,11 @@ int finallyThrow(int x) {
|
|||
|
||||
const var3 = unhandledThrow(0);
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
const var4 = unhandledThrow("string");
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int unhandledThrow(dynamic x) {
|
||||
try {
|
||||
|
@ -46,7 +46,7 @@ int unhandledThrow(dynamic x) {
|
|||
|
||||
const var5 = unhandledThrow2();
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int unhandledThrow2() {
|
||||
int count = 0;
|
||||
|
|
|
@ -10,10 +10,10 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = fn("s");
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var2 = fn(1);
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn(dynamic error) {
|
||||
try {
|
||||
throw error;
|
||||
|
@ -26,10 +26,10 @@ int fn(dynamic error) {
|
|||
|
||||
const var3 = fn1(10);
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var4 = fn1("s");
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn1(dynamic error) {
|
||||
try {
|
||||
throw error;
|
||||
|
@ -42,13 +42,13 @@ int fn1(dynamic error) {
|
|||
|
||||
const var5 = finallyReturn(10);
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var6 = finallyReturn("s");
|
||||
// ^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var7 = finallyReturn(1);
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int finallyReturn(dynamic error) {
|
||||
try {
|
||||
if (error != 1) throw error;
|
||||
|
@ -63,10 +63,10 @@ int finallyReturn(dynamic error) {
|
|||
|
||||
const var8 = finallyReturn1(0);
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var9 = finallyReturn1(1);
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int finallyReturn1(int x) {
|
||||
try {
|
||||
if (x == 1) {
|
||||
|
@ -81,7 +81,7 @@ int finallyReturn1(int x) {
|
|||
|
||||
const var10 = finallyMutate();
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int finallyMutate() {
|
||||
int x = 0;
|
||||
try {
|
||||
|
@ -93,7 +93,7 @@ int finallyMutate() {
|
|||
|
||||
const var11 = subtypeFn();
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int subtypeFn() {
|
||||
try {
|
||||
throw 2.5;
|
||||
|
@ -104,7 +104,7 @@ int subtypeFn() {
|
|||
|
||||
const var12 = orderFn();
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
String orderFn() {
|
||||
String x = "st";
|
||||
try {
|
||||
|
@ -119,7 +119,7 @@ String orderFn() {
|
|||
|
||||
const var13 = notThrowStatement();
|
||||
// ^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int notThrowStatement() {
|
||||
int count = 0;
|
||||
try {
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = varAssignmentTest(1);
|
||||
// ^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int varAssignmentTest(int a) {
|
||||
int x = 4;
|
||||
{
|
||||
|
@ -28,16 +28,16 @@ int function() {
|
|||
|
||||
const var2 = varAssignmentTest2();
|
||||
// ^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
return var2;
|
||||
}
|
||||
|
||||
const var3 = varAssignmentTest3(1);
|
||||
// ^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var4 = varAssignmentTest3(2);
|
||||
// ^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int varAssignmentTest3(int a) {
|
||||
int x = 4;
|
||||
x = a + 1;
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = fn1();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int fn1() {
|
||||
var a;
|
||||
|
@ -19,7 +19,7 @@ int fn1() {
|
|||
|
||||
const var2 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int fn2() {
|
||||
var x;
|
||||
|
|
|
@ -10,10 +10,10 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = function1(1, 2);
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var1_1 = function1(2, 2);
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int function1(int a, int b) {
|
||||
var x = 1 + a + b;
|
||||
return x;
|
||||
|
@ -21,7 +21,7 @@ int function1(int a, int b) {
|
|||
|
||||
const var2 = function2();
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
String function2() {
|
||||
dynamic x = "string";
|
||||
return x;
|
||||
|
@ -29,7 +29,7 @@ String function2() {
|
|||
|
||||
const var3 = function3();
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int function3() {
|
||||
var first = 2;
|
||||
var second = 2 + first;
|
||||
|
@ -38,7 +38,7 @@ int function3() {
|
|||
|
||||
const var4 = function4();
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int function4() {
|
||||
var first = 2;
|
||||
var second = 0;
|
||||
|
@ -47,7 +47,7 @@ int function4() {
|
|||
|
||||
const var5 = function5();
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int function5() {
|
||||
const constant = -2;
|
||||
return constant;
|
||||
|
@ -55,7 +55,7 @@ int function5() {
|
|||
|
||||
const var6 = function6();
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int function6() {
|
||||
var a;
|
||||
a = 2;
|
||||
|
@ -64,7 +64,7 @@ int function6() {
|
|||
|
||||
const var7 = function7();
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int function7() {
|
||||
var a;
|
||||
var b;
|
||||
|
@ -74,7 +74,7 @@ int function7() {
|
|||
|
||||
const var8 = function8();
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int function8() {
|
||||
var a;
|
||||
int? b;
|
||||
|
@ -84,7 +84,7 @@ int function8() {
|
|||
|
||||
const var9 = function9();
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int? function9() {
|
||||
int? x;
|
||||
return x;
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = fn();
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn() {
|
||||
int val = 0;
|
||||
while (val) {
|
||||
|
@ -24,7 +24,7 @@ int fn() {
|
|||
|
||||
const var2 = fn2();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int fn2() {
|
||||
int val = 0;
|
||||
|
@ -36,7 +36,7 @@ int fn2() {
|
|||
|
||||
const var3 = fn3();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Constant evaluation error:
|
||||
int fn3() {
|
||||
dynamic val = 0;
|
||||
|
|
|
@ -10,10 +10,10 @@ import "package:expect/expect.dart";
|
|||
|
||||
const var1 = fn(2);
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var2 = fn(3);
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn(int a) {
|
||||
int b = a;
|
||||
int i = 0;
|
||||
|
@ -26,10 +26,10 @@ int fn(int a) {
|
|||
|
||||
const var3 = fn1(2);
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var4 = fn1(3);
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fn1(int a) {
|
||||
int b = a;
|
||||
while (true) {
|
||||
|
@ -40,7 +40,7 @@ int fn1(int a) {
|
|||
|
||||
const var5 = fnContinue();
|
||||
// ^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fnContinue() {
|
||||
int a = 0;
|
||||
int i = 0;
|
||||
|
@ -57,10 +57,10 @@ int fnContinue() {
|
|||
|
||||
const var6 = fnBreak(2);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
const var7 = fnBreak(3);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fnBreak(int a) {
|
||||
int b = a;
|
||||
int i = 0;
|
||||
|
@ -74,7 +74,7 @@ int fnBreak(int a) {
|
|||
|
||||
const var8 = fnNestedWhile();
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fnNestedWhile() {
|
||||
int a = 0;
|
||||
while (true) {
|
||||
|
@ -87,7 +87,7 @@ int fnNestedWhile() {
|
|||
|
||||
const var9 = fnBreakLabel();
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
int fnBreakLabel() {
|
||||
foo:
|
||||
while (true) {
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
// @dart = 2.9
|
||||
|
||||
const m0 = const {499: 400 + 99};
|
||||
const m1 = const {
|
||||
"foo" + "bar": 42
|
||||
};
|
||||
const m1 = const {"foo" + "bar": 42};
|
||||
const m2 = const {
|
||||
// ^
|
||||
// [cfe] Constant evaluation error:
|
||||
|
@ -18,9 +16,7 @@ const m2 = const {
|
|||
const m3 = const {
|
||||
"foo".codeUnitAt(0): 42
|
||||
//^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
//^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.NON_CONSTANT_MAP_KEY
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// ^
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@ void main() {
|
|||
const c5 = constField;
|
||||
const c6 = method();
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
const c7 = new Class();
|
||||
// ^^^^^^^^^^^
|
||||
|
|
|
@ -9,13 +9,13 @@ class C {
|
|||
}
|
||||
|
||||
const
|
||||
// [error line 11, column 1, length 5]
|
||||
// [error column 1, length 5]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
|
||||
// [cfe] Can't have modifier 'const' here.
|
||||
t() => null;
|
||||
|
||||
const
|
||||
// [error line 17, column 1, length 5]
|
||||
// [error column 1, length 5]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
|
||||
// [cfe] Can't have modifier 'const' here.
|
||||
get v => null;
|
||||
|
@ -24,7 +24,7 @@ main() {
|
|||
const
|
||||
dynamic x = t();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
const y = const C();
|
||||
// ^^^^^
|
||||
|
|
|
@ -8,7 +8,8 @@ import "package:expect/expect.dart";
|
|||
|
||||
class A {
|
||||
final int i = f();
|
||||
// ^
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_METHOD_INVOCATION
|
||||
// [cfe] Method invocation is not a constant expression.
|
||||
final int j = 1;
|
||||
const A();
|
||||
|
|
Loading…
Reference in a new issue