Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4fc52cd

Browse files
zmthymichaelficarra
authored andcommitted
Fixes jashkenas#1467. Catch now introduces its parameter to scope.
1 parent 4af47f0 commit 4fc52cd

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/nodes.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,7 @@ exports.Try = class Try extends Base
14021402
o.indent += TAB
14031403
errorPart = if @error then " (#{ @error.compile o }) " else ' '
14041404
catchPart = if @recovery
1405+
o.scope.add @error.value, 'param'
14051406
" catch#{errorPart}{\n#{ @recovery.compile o, LEVEL_TOP }\n#{@tab}}"
14061407
else unless @ensure or @recovery
14071408
' catch (_e) {}'

test/scope.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ test "siblings of variadic arguments shouldn't break out.", ->
2626
oops = (x,args...) ->
2727
oops(20, 1,2,3)
2828
eq x, 10
29+
30+
test "catch statements should introduce their argument to scope", ->
31+
try throw ''
32+
catch e
33+
do -> e = 5
34+
eq 5, e

0 commit comments

Comments
 (0)