[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

@@ -3255,7 +3255,7 @@ exports.Throw = class Throw extends Base
makeReturn: THIS
compileNode: (o) ->
fragments = @expression.compileToFragments o
fragments = @expression.compileToFragments o, LEVEL_LIST
unshiftAfterComments fragments, @makeCode 'throw '
fragments.unshift @makeCode @tab
fragments.push @makeCode ';'