Skip to content

Commit 18e1ec4

Browse files
committed
Fix jashkenas#3789: don’t throw a throw (unless it’s in a closure)
1 parent bcc6384 commit 18e1ec4

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

lib/coffeescript/nodes.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

+1
Original file line numberDiff line numberDiff line change
@@ -3258,6 +3258,7 @@ exports.Throw = class Throw extends Base
32583258
if @expression instanceof For or
32593259
@expression instanceof If or
32603260
@expression instanceof Switch or
3261+
@expression instanceof Throw or
32613262
@expression instanceof While
32623263
fragments = @expression.compileClosure o
32633264
else

test/exception_handling.coffee

+6
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,9 @@ test "#3709: throwing a while loop", ->
176176
i++
177177
catch err
178178
eq i, 3
179+
180+
test "#3789: throwing a throw", ->
181+
try
182+
throw throw throw new Error 'whoa!'
183+
catch err
184+
eq err.message, 'whoa!'

0 commit comments

Comments
 (0)