Closed dead-claudia closed 6 years ago
Semantically, the labels are meaningless after parsing
Not sure what this means. The obvious interpretation is false: for example,
switch (0) {
default: break;
case console.log(42):
}
will print 42
. Contrast
switch (0) {
case 0:
default: break;
case console.log(42):
}
which has no effects.
Similarly,
switch (0) {
case -1: console.log(-1); break;
default: console.log('default'); break;
case 1: console.log(1); break;
case 0: console.log(0); break;
case 2: console.log(2); break;
}
will print 0
.
See step 9 of the third item under CaseBlockEvaluation (the CaseBlock : { CaseClauses DefaultClause CaseClauses }
production).
Oh, then on that note, nevermind.
Semantically, the labels are meaningless after parsing, so why include them as part of the AST?
In case you're wondering what precedent there is for just ignoring the extra
case
labels:case
anddefault
. (The minifier still strips them as dead code, however.)