mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
added Stan's fix for try/finally without catch
This commit is contained in:
parent
2a47727641
commit
f2d0aee656
3 changed files with 16 additions and 2 deletions
|
@ -1195,7 +1195,7 @@ idt += TAB
|
|||
o.top = true;
|
||||
attempt_part = this.attempt.compile(o);
|
||||
error_part = this.error ? " (" + (this.error.compile(o)) + ") " : ' ';
|
||||
catch_part = '' + ((this.recovery || '') && ' catch') + error_part + "{\n" + (this.recovery.compile(o)) + "\n" + this.tab + "}";
|
||||
catch_part = this.recovery ? " catch" + error_part + "{\n" + (this.recovery.compile(o)) + "\n" + this.tab + "}" : '';
|
||||
finally_part = (this.ensure || '') && ' finally {\n' + this.ensure.compile(merge(o, {
|
||||
returns: null
|
||||
})) + "\n" + this.tab + "}";
|
||||
|
|
|
@ -905,7 +905,7 @@ exports.TryNode: class TryNode extends BaseNode
|
|||
o.top: true
|
||||
attempt_part: @attempt.compile(o)
|
||||
error_part: if @error then " (${ @error.compile(o) }) " else ' '
|
||||
catch_part: "${ (@recovery or '') and ' catch' }$error_part{\n${ @recovery.compile(o) }\n$@tab}"
|
||||
catch_part: if @recovery then " catch$error_part{\n${ @recovery.compile(o) }\n$@tab}" else ''
|
||||
finally_part: (@ensure or '') and ' finally {\n' + @ensure.compile(merge(o, {returns: null})) + "\n$@tab}"
|
||||
"${@tab}try {\n$attempt_part\n$@tab}$catch_part$finally_part"
|
||||
|
||||
|
|
14
test/test_try_catch.coffee
Normal file
14
test/test_try_catch.coffee
Normal file
|
@ -0,0 +1,14 @@
|
|||
result: try
|
||||
10
|
||||
finally
|
||||
15
|
||||
|
||||
ok result is 10
|
||||
|
||||
|
||||
result: try
|
||||
throw 'up'
|
||||
catch err
|
||||
err.length
|
||||
|
||||
ok result is 2
|
Loading…
Add table
Reference in a new issue