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

Unified Diff: gen.dart

Issue 8399010: Fixed compiler so that it passes Switch1NegativeTest.dart. (Closed) Base URL: http://dart.googlecode.com/svn/experimental/frog/
Patch Set: '' Created 9 years, 2 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
Index: gen.dart
===================================================================
--- gen.dart (revision 839)
+++ gen.dart (working copy)
@@ -1340,6 +1340,10 @@
for (int i=0; i < case_.cases.length; i++) {
var expr = case_.cases[i];
if (expr == null) {
+ // Default can only be the last case.
+ if (i < case_.cases.length - 1) {
+ world.error('default clause must be the last case', case_.span);
+ }
writer.writeln('default:');
} else {
var value = visitValue(expr);
@@ -1350,6 +1354,14 @@
for (var stmt in case_.statements) {
stmt.visit(this);
jimhug 2011/10/27 17:45:11 This needs to do some sort of minimal checking for
Emily Fortuna 2011/10/27 17:59:04 Done in the next CL.
}
+ if (case_ != node.cases[node.cases.length - 1]) {
+ var span = case_.statements[case_.statements.length - 1].span;
+ //TODO(efortuna): This error message isn't 100% correct because
+ // constructors are not being built correctly. Check back when I've
+ // fixed constructors.
+ writer.writeln('\$throw(new FallThroughError("${span.file.filename}",' +
+ ' ${span.file.getLine(span.start)}))');
+ }
writer.exitBlock('');
_popBlock();
}

Powered by Google App Engine
This is Rietveld 408576698