aboutsummaryrefslogtreecommitdiff
path: root/lib/parse.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/parse.js')
-rw-r--r--lib/parse.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/parse.js b/lib/parse.js
index abbf2df4..3a1f809b 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -1092,7 +1092,7 @@ function parse($TEXT, options) {
function switch_body_() {
expect("{");
- var a = [], cur = null, branch = null, tmp;
+ var a = [], branch, cur, default_branch, tmp;
while (!is("punc", "}")) {
if (is("eof")) expect_token("punc", "}");
if (is("keyword", "case")) {
@@ -1107,12 +1107,14 @@ function parse($TEXT, options) {
expect(":");
} else if (is("keyword", "default")) {
if (branch) branch.end = prev();
+ if (default_branch) croak("More than one default clause in switch statement");
cur = [];
branch = new AST_Default({
start : (tmp = S.token, next(), expect(":"), tmp),
body : cur
});
a.push(branch);
+ default_branch = branch;
} else {
if (!cur) unexpected();
cur.push(statement());