diff --git a/lib/coffee-script/nodes.js b/lib/coffee-script/nodes.js index 534811e5..ce72224f 100644 --- a/lib/coffee-script/nodes.js +++ b/lib/coffee-script/nodes.js @@ -2721,7 +2721,9 @@ var catchPart, ensurePart, generatedErrorVariableName, placeholder, tryPart; o.indent += TAB; tryPart = this.attempt.compileToFragments(o, LEVEL_TOP); - catchPart = this.recovery ? (generatedErrorVariableName = o.scope.freeVariable('error'), placeholder = new Literal(generatedErrorVariableName), this.errorVariable ? this.recovery.unshift(new Assign(this.errorVariable, placeholder)) : void 0, [].concat(this.makeCode(" catch ("), placeholder.compileToFragments(o), this.makeCode(") {\n"), this.recovery.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}"))) : !(this.ensure || this.recovery) ? [this.makeCode(" catch (" + generatedErrorVariableName + ") {}")] : []; + catchPart = this.recovery ? (generatedErrorVariableName = o.scope.freeVariable('error', { + reserve: false + }), placeholder = new Literal(generatedErrorVariableName), this.errorVariable ? this.recovery.unshift(new Assign(this.errorVariable, placeholder)) : void 0, [].concat(this.makeCode(" catch ("), placeholder.compileToFragments(o), this.makeCode(") {\n"), this.recovery.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}"))) : !(this.ensure || this.recovery) ? [this.makeCode(" catch (" + generatedErrorVariableName + ") {}")] : []; ensurePart = this.ensure ? [].concat(this.makeCode(" finally {\n"), this.ensure.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}")) : []; return [].concat(this.makeCode(this.tab + "try {\n"), tryPart, this.makeCode("\n" + this.tab + "}"), catchPart, ensurePart); }; diff --git a/src/nodes.coffee b/src/nodes.coffee index 5f2c1a81..9f095d2b 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1920,7 +1920,7 @@ exports.Try = class Try extends Base tryPart = @attempt.compileToFragments o, LEVEL_TOP catchPart = if @recovery - generatedErrorVariableName = o.scope.freeVariable 'error' + generatedErrorVariableName = o.scope.freeVariable 'error', reserve: no placeholder = new Literal generatedErrorVariableName @recovery.unshift new Assign @errorVariable, placeholder if @errorVariable [].concat @makeCode(" catch ("), placeholder.compileToFragments(o), @makeCode(") {\n"),