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

Issue 8343037: Throw FallThroughError when we fall through a case in a switch statement. Fixes (Closed)

Created:
9 years, 1 month ago by Emily Fortuna
Modified:
9 years, 1 month ago
Reviewers:
jimhug
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Throw FallThroughError when we fall through a case in a switch statement. Fixes two tests. Committed: https://code.google.com/p/dart/source/detail?r=918

Patch Set 1 #

Patch Set 2 : '' #

Total comments: 14

Patch Set 3 : '' #

Patch Set 4 : '' #

Total comments: 8

Patch Set 5 : '' #

Patch Set 6 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+767 lines, -676 lines) Patch
M frogsh View 1 2 3 4 5 241 chunks +673 lines, -639 lines 0 comments Download
M gen.dart View 1 2 3 4 5 16 chunks +82 lines, -32 lines 0 comments Download
M lib/corelib.dart View 1 2 3 4 5 1 chunk +8 lines, -1 line 0 comments Download
M parser.dart View 1 2 3 4 5 2 chunks +3 lines, -1 line 0 comments Download
M tests/frog/frog.status View 1 2 3 4 5 2 chunks +0 lines, -2 lines 0 comments Download
M tree.dart View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 5 (0 generated)
Emily Fortuna
http://codereview.chromium.org/8343037/diff/2001/gen.dart File gen.dart (right): http://codereview.chromium.org/8343037/diff/2001/gen.dart#newcode1390 gen.dart:1390: returns = stmt.visit(this); I should add a warning here ...
9 years, 1 month ago (2011-10-27 22:11:24 UTC) #1
jimhug
This is moving in the right direction! I just have a few things for you ...
9 years, 1 month ago (2011-10-28 14:33:34 UTC) #2
Emily Fortuna
http://codereview.chromium.org/8343037/diff/2001/gen.dart File gen.dart (right): http://codereview.chromium.org/8343037/diff/2001/gen.dart#newcode1145 gen.dart:1145: var return1, return2; I tested this out before I ...
9 years, 1 month ago (2011-10-28 17:23:23 UTC) #3
Emily Fortuna
PTAL. On 2011/10/28 17:23:23, efortuna wrote: > http://codereview.chromium.org/8343037/diff/2001/gen.dart > File gen.dart (right): > > http://codereview.chromium.org/8343037/diff/2001/gen.dart#newcode1145 ...
9 years, 1 month ago (2011-10-28 18:39:08 UTC) #4
jimhug
9 years, 1 month ago (2011-10-28 20:02:44 UTC) #5
LGTM!

There are some TODOs in here - but those can easily wait for a future CL.  As
far as your fix to the parser for labeled case statements - is this covered by
an existing test case?  If not we should file an issue that we need a test here
for the future.

http://codereview.chromium.org/8343037/diff/5002/frogsh
File frogsh (right):

http://codereview.chromium.org/8343037/diff/5002/frogsh#newcode2567
frogsh:2567: $throw(new FallThroughError("./leg/scanner/scanner.dart", 389))
Please send Peter Ahe and email pointing this change out to him and explaining
the reasons for it.  He is very carefully tracking the performance of this code
and it is vaguely possible that he will see a perf regression.  I think this is
clearly the right choice for correctness now - and more analysis to reduce code
size later - but I'd prefer that Peter not be surprised.

http://codereview.chromium.org/8343037/diff/5002/gen.dart
File gen.dart (right):

http://codereview.chromium.org/8343037/diff/5002/gen.dart#newcode1056
gen.dart:1056: exit1 = node.trueBranch.visit(this);
I'd move the var decl to this line as I really like declaring and initializing
variables in one line.

http://codereview.chromium.org/8343037/diff/5002/gen.dart#newcode1253
gen.dart:1253: writer.exitBlock('}');
Add a TODO: This could be more precise by combining all the different paths
here.  -i.e. if there is a finally block with a return at the end then this can
return true, similarly if all blocks have a return at the end then the same
holds.

http://codereview.chromium.org/8343037/diff/5002/gen.dart#newcode1285
gen.dart:1285: world.warning('unreachable code', case_.statements[i + 1].span);
Don't worry about it in this checkin - but for a future TODO - this will
generate a lot of errors if I have:
  case 0:
    return 1;
    a;
    b;
    c;

As written, this will give me three errors - and I'd prefer to just get the
error on a.

http://codereview.chromium.org/8343037/diff/5002/gen.dart#newcode1303
gen.dart:1303: // statement.
Nice TODO.

http://codereview.chromium.org/8343037/diff/5002/gen.dart#newcode1314
gen.dart:1314: if (exits && stmt != node.body[node.body.length - 1]) {
TODO: Again, not for this checkin - but the same statement as above applies here
for getting only one error.  Now that I think about it, this code should
probably be factored out to be shared there - as well as by
visitStatementsInBlock as well - where you are currently missing the error
message.

http://codereview.chromium.org/8343037/diff/5002/parser.dart
File parser.dart (right):

http://codereview.chromium.org/8343037/diff/5002/parser.dart#newcode632
parser.dart:632: label = identifier();
Whoa!  How was this working before?

http://codereview.chromium.org/8343037/diff/5002/tree.dart
File tree.dart (left):

http://codereview.chromium.org/8343037/diff/5002/tree.dart#oldcode14
tree.dart:14: abstract void visit(TreeVisitor visitor);
Good catch.

Powered by Google App Engine
This is Rietveld 408576698