archives

« Bugzilla Issues Index

#345 — Error in specification of switch statement 12.11


There is an error in the specification of the switch statement in 12.11.

A switch statement like:

switch (100) {
case 1: alert(1);
default: alert("default");
case 2: alert(2);
}

should alert "default" followed by "2" because there isn't a break statement at the end of the default clause's statement list.

As specified in the ES5/5.1 spec. the "2" will not appear. The loop in step is intended to evaluate all of the statement list following the default clause in situations like this. However, as written is doesn't because list B has already been iterated to its end by the loop in 7.a.

The correction is to add a new step between 8 and 9 that says:
If foundInB is false, reset list B to so it will iterate from its beginning.

also the note in step 9 should be modified to say set 7.a.iii.1 instead of 7.a.i


marked as in progress to indiate in need to go into the errata


Bulk resolving ES5.1 errata issues as a sampling suggests these are all fixed. If this is in error, please open a new issue on GitHub.