diff --git a/lib/coffee-script/cake.js b/lib/coffee-script/cake.js index 60f0dbee..db24f46e 100644 --- a/lib/coffee-script/cake.js +++ b/lib/coffee-script/cake.js @@ -46,7 +46,7 @@ }); exports.run = function() { - var arg, args, e, i, len, ref, results; + var _error, arg, args, e, i, len, ref, results; global.__originalDirname = fs.realpathSync('.'); process.chdir(cakefileDirectory(__originalDirname)); args = process.argv.slice(2); diff --git a/lib/coffee-script/coffee-script.js b/lib/coffee-script/coffee-script.js index 9dc7c710..7345413b 100644 --- a/lib/coffee-script/coffee-script.js +++ b/lib/coffee-script/coffee-script.js @@ -26,7 +26,7 @@ withPrettyErrors = function(fn) { return function(code, options) { - var err; + var _error, err; if (options == null) { options = {}; } @@ -217,7 +217,7 @@ } exports._compileFile = function(filename, sourceMap) { - var answer, err, raw, stripped; + var _error, answer, err, raw, stripped; if (sourceMap == null) { sourceMap = false; } diff --git a/lib/coffee-script/command.js b/lib/coffee-script/command.js index cc1adee8..7a83947d 100644 --- a/lib/coffee-script/command.js +++ b/lib/coffee-script/command.js @@ -112,7 +112,7 @@ }; compilePath = function(source, topLevel, base) { - var code, err, file, files, i, len, results, stats; + var _error, _error1, _error2, code, err, file, files, i, len, results, stats; if (indexOf.call(sources, source) >= 0 || watchedDirs[source] || !topLevel && (notSources[source] || hidden(source))) { return; } @@ -140,8 +140,8 @@ } try { files = fs.readdirSync(source); - } catch (_error) { - err = _error; + } catch (_error1) { + err = _error1; if (err.code === 'ENOENT') { return; } else { @@ -163,8 +163,8 @@ } try { code = fs.readFileSync(source); - } catch (_error) { - err = _error; + } catch (_error2) { + err = _error2; if (err.code === 'ENOENT') { return; } else { @@ -178,7 +178,7 @@ }; findDirectoryIndex = function(source) { - var err, ext, i, index, len, ref1; + var _error, err, ext, i, index, len, ref1; ref1 = CoffeeScript.FILE_EXTENSIONS; for (i = 0, len = ref1.length; i < len; i++) { ext = ref1[i]; @@ -199,7 +199,7 @@ }; compileScript = function(file, input, base) { - var compiled, err, message, o, options, t, task; + var _error, compiled, err, message, o, options, t, task; if (base == null) { base = null; } @@ -289,11 +289,12 @@ }; watch = function(source, base) { - var compile, compileTimeout, err, prevStats, rewatch, startWatcher, watchErr, watcher; + var _error, compile, compileTimeout, err, prevStats, rewatch, startWatcher, watchErr, watcher; watcher = null; prevStats = null; compileTimeout = null; watchErr = function(err) { + var _error; if (err.code !== 'ENOENT') { throw err; } @@ -352,7 +353,7 @@ }; watchDir = function(source, base) { - var err, readdirTimeout, startWatcher, stopWatcher, watcher; + var _error, err, readdirTimeout, startWatcher, stopWatcher, watcher; watcher = null; readdirTimeout = null; startWatcher = function() { @@ -364,7 +365,7 @@ }).on('change', function() { clearTimeout(readdirTimeout); return readdirTimeout = wait(25, function() { - var err, file, files, i, len, results; + var _error, err, file, files, i, len, results; try { files = fs.readdirSync(source); } catch (_error) { @@ -428,7 +429,7 @@ }; silentUnlink = function(path) { - var err, ref1; + var _error, err, ref1; try { return fs.unlinkSync(path); } catch (_error) { diff --git a/lib/coffee-script/nodes.js b/lib/coffee-script/nodes.js index 2144d539..40b029e0 100644 --- a/lib/coffee-script/nodes.js +++ b/lib/coffee-script/nodes.js @@ -2688,7 +2688,7 @@ o.indent += TAB; scope = o.scope; tryPart = this.attempt.compileToFragments(o, LEVEL_TOP); - catchPart = this.recovery ? (generatedErrorVariableName = 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 = 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 + ") {}")] : []; 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/lib/coffee-script/repl.js b/lib/coffee-script/repl.js index 4c67d05d..1766836e 100644 --- a/lib/coffee-script/repl.js +++ b/lib/coffee-script/repl.js @@ -19,7 +19,7 @@ historyFile: process.env.HOME ? path.join(process.env.HOME, '.coffee_history') : void 0, historyMaxInputSize: 10240, "eval": function(input, context, filename, cb) { - var Assign, Block, Literal, Value, ast, err, js, ref1, referencedVars, token, tokens; + var Assign, Block, Literal, Value, _error, ast, err, js, ref1, referencedVars, token, tokens; input = input.replace(/\uFF00/g, '\n'); input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1'); ref1 = require('./nodes'), Block = ref1.Block, Assign = ref1.Assign, Value = ref1.Value, Literal = ref1.Literal; diff --git a/src/nodes.coffee b/src/nodes.coffee index 0bb468db..94afb73d 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1896,7 +1896,7 @@ exports.Try = class Try extends Base tryPart = @attempt.compileToFragments o, LEVEL_TOP catchPart = if @recovery - generatedErrorVariableName = scope.freeVariable '_error' + generatedErrorVariableName = scope.freeVariable 'error' placeholder = new Literal generatedErrorVariableName @recovery.unshift new Assign @errorVariable, placeholder if @errorVariable [].concat @makeCode(" catch ("), placeholder.compileToFragments(o), @makeCode(") {\n"), diff --git a/test/assignment.coffee b/test/assignment.coffee index 12e6b640..988618fc 100644 --- a/test/assignment.coffee +++ b/test/assignment.coffee @@ -444,16 +444,10 @@ test "#1500: Assignment to variables similar to generated variables", -> eq 1, scope.a try throw 'foo' - catch _error - eq _error, 'foo' + catch error + eq error, 'foo' - eq _error, 'foo' - - try throw 'bar' - catch __error - eq __error, 'bar' - - eq __error, 'bar' + eq error, 'foo' doesNotThrow -> CoffeeScript.compile '(@slice...) ->'