[CS2] Fix #3709, #3789: ‘throw’ an ‘if’, ‘for’, ‘switch’, ‘while’ (#4664)

* Fix #3709: throwing an if, for, switch or while should throw the returned value of the statement/loop

* Fix #3789: don’t throw a throw (unless it’s in a closure)

* LEVEL_LIST works better than a list of node types
This commit is contained in:
Geoffrey Booth
2017-08-25 11:11:10 -07:00
committed by GitHub
parent c81e2d4767
commit 7c627f9dfd
3 changed files with 57 additions and 15 deletions

View File

@@ -4774,7 +4774,7 @@
compileNode(o) {
var fragments;
fragments = this.expression.compileToFragments(o);
fragments = this.expression.compileToFragments(o, LEVEL_LIST);
unshiftAfterComments(fragments, this.makeCode('throw '));
fragments.unshift(this.makeCode(this.tab));
fragments.push(this.makeCode(';'));