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

Unified Diff: dart/pkg/compiler/lib/src/compile_time_constants.dart

Issue 829033004: Non-fatal errors in compile-time constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r42767. Created 5 years, 11 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 | « no previous file | dart/pkg/compiler/lib/src/constants/expressions.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/pkg/compiler/lib/src/compile_time_constants.dart
diff --git a/dart/pkg/compiler/lib/src/compile_time_constants.dart b/dart/pkg/compiler/lib/src/compile_time_constants.dart
index 5115f4a2c0e0a54f901a2c7178bd741b6c28f5d5..24bacbee599ac77e42007a69215e351278bfa496 100644
--- a/dart/pkg/compiler/lib/src/compile_time_constants.dart
+++ b/dart/pkg/compiler/lib/src/compile_time_constants.dart
@@ -135,8 +135,7 @@ abstract class ConstantCompilerBase implements ConstantCompiler {
if (isConst) {
compiler.reportError(
node, MessageKind.CYCLIC_COMPILE_TIME_CONSTANTS);
- // TODO(ahe): Don't throw, recover from error.
- throw new CompilerCancelledException(null);
+ return new ErroneousConstantExpression();
}
return null;
}
@@ -620,8 +619,7 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
compiler.reportError(
node.condition, MessageKind.NOT_ASSIGNABLE,
{'fromType': conditionType, 'toType': compiler.boolClass.rawType});
- // TODO(ahe): Don't throw, recover from error.
- throw new CompilerCancelledException(null);
+ return new ErroneousAstConstant(context, node);
}
return null;
}
@@ -673,8 +671,10 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
node,
MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS,
{'constructorName': name});
- // TODO(ahe): Don't throw, recover from error.
- throw new CompilerCancelledException(null);
+
+ return new List<AstConstant>.filled(
+ target.functionSignature.parameterCount,
+ new ErroneousAstConstant(context, node));
}
return selector.makeArgumentsList2(arguments,
target,
@@ -826,7 +826,8 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
Selector selector,
List<AstConstant> concreteArguments,
List<AstConstant> normalizedArguments) {
- assert(invariant(node, selector.applies(constructor, compiler.world),
+ assert(invariant(node, selector.applies(constructor, compiler.world) ||
+ compiler.compilationFailed,
message: "Selector $selector does not apply to constructor "
"$constructor."));
@@ -1117,4 +1118,10 @@ class AstConstant {
ConstantValue get value => expression.value;
String toString() => expression.toString();
-}
+}
+
+/// A synthetic constant used to recover from errors.
+class ErroneousAstConstant extends AstConstant {
+ ErroneousAstConstant(Element element, Node node)
+ : super(element, node, new ErroneousConstantExpression());
+}
« no previous file with comments | « no previous file | dart/pkg/compiler/lib/src/constants/expressions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698