mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 03:21:20 -05:00
Fixing #600. JS statements that must be expressions but contain pure statements cause syntax errors.
This commit is contained in:
14
lib/nodes.js
14
lib/nodes.js
@@ -31,13 +31,13 @@
|
||||
this.options = o ? merge(o) : {};
|
||||
this.tab = o.indent;
|
||||
top = this.topSensitive() ? this.options.top : del(this.options, 'top');
|
||||
closure = this.isStatement(o) && !this.isPureStatement() && !top && !this.options.asStatement && !(this instanceof Comment) && !this.containsPureStatement();
|
||||
closure = this.isStatement(o) && !this.isPureStatement() && !top && !this.options.asStatement && !(this instanceof Comment);
|
||||
code = closure ? this.compileClosure(this.options) : this.compileNode(this.options);
|
||||
return code;
|
||||
};
|
||||
Base.prototype.compileClosure = function(o) {
|
||||
o.sharedScope = o.scope;
|
||||
return Closure.wrap(this).compile(o);
|
||||
return Closure.wrap(this, false, true).compile(o);
|
||||
};
|
||||
Base.prototype.compileReference = function(o, options) {
|
||||
var _len, compiled, i, node, pair, reference;
|
||||
@@ -484,7 +484,7 @@
|
||||
var method, name;
|
||||
method = o.scope.method;
|
||||
if (!method) {
|
||||
throw Error("cannot call super outside of a function");
|
||||
throw Error("cannot call super outside of a function.");
|
||||
}
|
||||
name = method.name;
|
||||
if (!name) {
|
||||
@@ -1910,8 +1910,14 @@
|
||||
}
|
||||
};
|
||||
Closure = {
|
||||
wrap: function(expressions, statement) {
|
||||
wrap: function(expressions, statement, force) {
|
||||
var args, call, func, mentionsArgs, meth;
|
||||
if (expressions.containsPureStatement()) {
|
||||
if (!force) {
|
||||
return expressions;
|
||||
}
|
||||
throw new Error('cannot include a pure statement in an expression.');
|
||||
}
|
||||
if (expressions.containsPureStatement()) {
|
||||
return expressions;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user