Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Unified Diff: pkg/analyzer/lib/src/error/codes.dart

Issue 3003363002: Report compile time errors when assert initializers fail. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/constant/evaluation.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/error/codes.dart
diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart
index 346daf9b92f49aeb554cfe93ff87f678d6702561..58e844c252a59d21ca935bca44e6aded6d396f1b 100644
--- a/pkg/analyzer/lib/src/error/codes.dart
+++ b/pkg/analyzer/lib/src/error/codes.dart
@@ -639,6 +639,36 @@ class CompileTimeErrorCode extends ErrorCode {
"In constant expressions, operands of this operator must be of type "
"'num'.");
+ /**
+ * https://github.com/dart-lang/sdk/blob/master/docs/language/informal/assert-in-initializer-list.md
+ *
+ * During a const constructor invocation (that is, when the `const`
+ * constructor is invoked using the const prefix), if the assert fails,
+ * either due to boolean conversion when `r` is not a boolean value or due to
+ * assertion failure when `r` is `false`, it is treated like any other
+ * compile-time throw in a compile-time constant expression, and it causes
+ * a compile-time error.
+ */
+ static const CompileTimeErrorCode CONST_EVAL_THROWS_ASSERT_NOT_BOOL =
+ const CompileTimeErrorCode(
+ 'CONST_EVAL_THROWS_ASSERT_NOT_BOOL',
+ "In constant constructors the value of the condition of an assert "
+ "statement must be bool.");
+
+ /**
+ * https://github.com/dart-lang/sdk/blob/master/docs/language/informal/assert-in-initializer-list.md
+ *
+ * During a const constructor invocation (that is, when the `const`
+ * constructor is invoked using the const prefix), if the assert fails,
+ * either due to boolean conversion when `r` is not a boolean value or due to
+ * assertion failure when `r` is `false`, it is treated like any other
+ * compile-time throw in a compile-time constant expression, and it causes
+ * a compile-time error.
+ */
+ static const CompileTimeErrorCode CONST_EVAL_THROWS_ASSERT_FALSE =
+ const CompileTimeErrorCode('CONST_EVAL_THROWS_ASSERT_FALSE',
+ "Evaluation of this constant expression throws an AssertionError.");
+
/**
* 16.12.2 Const: It is a compile-time error if evaluation of a constant
* object results in an uncaught exception being thrown.
« no previous file with comments | « pkg/analyzer/lib/src/dart/constant/evaluation.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698