Fixes #2422 -- Catch clause scoping plus old IE
This commit is contained in:
parent
1b573412d3
commit
f8c6b494aa
|
@ -46,7 +46,7 @@
|
|||
});
|
||||
|
||||
exports.run = function() {
|
||||
var arg, args, _i, _len, _ref, _results;
|
||||
var arg, args, e, _i, _len, _ref, _results;
|
||||
global.__originalDirname = fs.realpathSync('.');
|
||||
process.chdir(cakefileDirectory(__originalDirname));
|
||||
args = process.argv.slice(2);
|
||||
|
@ -59,7 +59,8 @@
|
|||
}
|
||||
try {
|
||||
options = oparse.parse(args);
|
||||
} catch (e) {
|
||||
} catch (_error) {
|
||||
e = _error;
|
||||
return fatalError("" + e);
|
||||
}
|
||||
_ref = options["arguments"];
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
exports.helpers = helpers;
|
||||
|
||||
exports.compile = compile = function(code, options) {
|
||||
var answer, coffeeFile, currentColumn, currentLine, fragment, fragments, header, js, jsFile, merge, newLines, sourceMap, _j, _len1;
|
||||
var answer, coffeeFile, currentColumn, currentLine, err, fragment, fragments, header, js, jsFile, merge, newLines, sourceMap, _j, _len1;
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
|
@ -72,7 +72,8 @@
|
|||
}
|
||||
js += fragment.code;
|
||||
}
|
||||
} catch (err) {
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
if (options.filename) {
|
||||
err.message = "In " + options.filename + ", " + err.message;
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@
|
|||
};
|
||||
|
||||
compileScript = function(file, input, base) {
|
||||
var compiled, o, options, t, task;
|
||||
var compiled, err, o, options, t, task;
|
||||
o = opts;
|
||||
options = compileOptions(file);
|
||||
try {
|
||||
|
@ -186,7 +186,8 @@
|
|||
return lint(t.file, t.output);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
CoffeeScript.emit('failure', err, task);
|
||||
if (CoffeeScript.listeners('failure').length) {
|
||||
return;
|
||||
|
@ -230,7 +231,7 @@
|
|||
};
|
||||
|
||||
watch = function(source, base) {
|
||||
var compile, compileTimeout, prevStats, rewatch, watchErr, watcher;
|
||||
var compile, compileTimeout, e, prevStats, rewatch, watchErr, watcher;
|
||||
prevStats = null;
|
||||
compileTimeout = null;
|
||||
watchErr = function(e) {
|
||||
|
@ -241,7 +242,8 @@
|
|||
try {
|
||||
rewatch();
|
||||
return compile();
|
||||
} catch (e) {
|
||||
} catch (_error) {
|
||||
e = _error;
|
||||
removeSource(source, base, true);
|
||||
return compileJoin();
|
||||
}
|
||||
|
@ -272,7 +274,8 @@
|
|||
};
|
||||
try {
|
||||
watcher = fs.watch(source, compile);
|
||||
} catch (e) {
|
||||
} catch (_error) {
|
||||
e = _error;
|
||||
watchErr(e);
|
||||
}
|
||||
return rewatch = function() {
|
||||
|
@ -284,7 +287,7 @@
|
|||
};
|
||||
|
||||
watchDir = function(source, base) {
|
||||
var readdirTimeout, watcher;
|
||||
var e, readdirTimeout, watcher;
|
||||
readdirTimeout = null;
|
||||
try {
|
||||
return watcher = fs.watch(source, function() {
|
||||
|
@ -319,7 +322,8 @@
|
|||
});
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
} catch (_error) {
|
||||
e = _error;
|
||||
if (e.code !== 'ENOENT') {
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -2499,19 +2499,14 @@
|
|||
o.indent += TAB;
|
||||
tryPart = this.attempt.compileToFragments(o, LEVEL_TOP);
|
||||
catchPart = (function() {
|
||||
var _base, _ref4;
|
||||
var _ref4;
|
||||
if (this.recovery) {
|
||||
if (typeof (_base = this.error).isObject === "function" ? _base.isObject() : void 0) {
|
||||
placeholder = new Literal('_error');
|
||||
this.recovery.unshift(new Assign(this.error, placeholder));
|
||||
this.error = placeholder;
|
||||
}
|
||||
if (_ref4 = this.error.value, __indexOf.call(STRICT_PROSCRIBED, _ref4) >= 0) {
|
||||
throw SyntaxError("catch variable may not be \"" + this.error.value + "\"");
|
||||
}
|
||||
if (!o.scope.check(this.error.value)) {
|
||||
o.scope.add(this.error.value, 'param');
|
||||
}
|
||||
return [].concat(this.makeCode(" catch ("), this.error.compileToFragments(o), this.makeCode(") {\n"), this.recovery.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}"));
|
||||
} else if (!(this.ensure || this.recovery)) {
|
||||
return [this.makeCode(' catch (_error) {}')];
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
replDefaults = {
|
||||
prompt: 'coffee> ',
|
||||
"eval": function(input, context, filename, cb) {
|
||||
var js;
|
||||
var err, js;
|
||||
input = input.replace(/\uFF00/g, '\n');
|
||||
input = input.replace(/(^|[\r\n]+)(\s*)##?(?:[^#\r\n][^\r\n]*|)($|[\r\n])/, '$1$2$3');
|
||||
if (/^(\s*|\(\s*\))$/.test(input)) {
|
||||
|
@ -25,7 +25,8 @@
|
|||
bare: true
|
||||
});
|
||||
return cb(null, vm.runInContext(js, context, filename));
|
||||
} catch (err) {
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
return cb(err);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1739,13 +1739,11 @@ exports.Try = class Try extends Base
|
|||
tryPart = @attempt.compileToFragments o, LEVEL_TOP
|
||||
|
||||
catchPart = if @recovery
|
||||
if @error.isObject?()
|
||||
placeholder = new Literal '_error'
|
||||
@recovery.unshift new Assign @error, placeholder
|
||||
@error = placeholder
|
||||
if @error.value in STRICT_PROSCRIBED
|
||||
throw SyntaxError "catch variable may not be \"#{@error.value}\""
|
||||
o.scope.add @error.value, 'param' unless o.scope.check @error.value
|
||||
[].concat @makeCode(" catch ("), @error.compileToFragments(o), @makeCode(") {\n"),
|
||||
@recovery.compileToFragments(o, LEVEL_TOP), @makeCode("\n#{@tab}}")
|
||||
else unless @ensure or @recovery
|
||||
|
|
Loading…
Reference in New Issue