mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
fixes #1844: bound functions in nested comprehensions
causing empty var statements
This commit is contained in:
parent
a296957771
commit
6d6a5f609a
8 changed files with 51 additions and 30 deletions
|
@ -1,6 +1,8 @@
|
|||
(function() {
|
||||
var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, Comment, Existence, Extends, For, IDENTIFIER, IDENTIFIER_STR, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, compact, del, ends, extend, flatten, last, merge, multident, starts, unfoldSoak, utility, _ref;
|
||||
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }, __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (__hasProp.call(this, i) && this[i] === item) return i; } return -1; };
|
||||
var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, Comment, Existence, Extends, For, IDENTIFIER, IDENTIFIER_STR, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, compact, del, ends, extend, flatten, last, merge, multident, starts, unfoldSoak, utility, _ref,
|
||||
__hasProp = Object.prototype.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; },
|
||||
__indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (__hasProp.call(this, i) && this[i] === item) return i; } return -1; };
|
||||
|
||||
Scope = require('./scope').Scope;
|
||||
|
||||
|
@ -312,7 +314,7 @@
|
|||
};
|
||||
|
||||
Block.prototype.compileWithDeclarations = function(o) {
|
||||
var assigns, code, declars, exp, i, post, rest, scope, _len, _ref2;
|
||||
var assigns, code, declars, exp, i, post, rest, scope, tab, _len, _ref2;
|
||||
code = post = '';
|
||||
_ref2 = this.expressions;
|
||||
for (i = 0, _len = _ref2.length; i < _len; i++) {
|
||||
|
@ -333,12 +335,19 @@
|
|||
if (scope.expressions === this) {
|
||||
declars = o.scope.hasDeclarations();
|
||||
assigns = scope.hasAssignments;
|
||||
if ((declars || assigns) && i) code += '\n';
|
||||
if (declars) {
|
||||
code += "" + this.tab + "var " + (scope.declaredVariables().join(', ')) + ";\n";
|
||||
}
|
||||
if (assigns) {
|
||||
code += "" + this.tab + "var " + (multident(scope.assignedVariables().join(', '), this.tab)) + ";\n";
|
||||
if (declars || assigns) {
|
||||
if (i) code += '\n';
|
||||
code += "" + this.tab + "var ";
|
||||
if (declars) code += scope.declaredVariables().join(', ');
|
||||
if (assigns) {
|
||||
tab = this.tab;
|
||||
if (declars) {
|
||||
tab += TAB;
|
||||
code += ",\n" + tab;
|
||||
}
|
||||
code += scope.assignedVariables().join(",\n" + tab);
|
||||
}
|
||||
code += ';\n';
|
||||
}
|
||||
}
|
||||
return code + post;
|
||||
|
@ -559,8 +568,8 @@
|
|||
};
|
||||
|
||||
Value.prototype.unfoldSoak = function(o) {
|
||||
var result;
|
||||
var _this = this;
|
||||
var result,
|
||||
_this = this;
|
||||
if (this.unfoldedSoak != null) return this.unfoldedSoak;
|
||||
result = (function() {
|
||||
var fst, i, ifn, prop, ref, snd, _len, _ref2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue