1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

fixing improperly-formatted-output of pattern matching within comprehension arguments.

This commit is contained in:
Jeremy Ashkenas 2010-07-03 15:09:21 -04:00
parent eefa004b8f
commit ec449158c6
3 changed files with 4 additions and 6 deletions

View file

@ -1476,7 +1476,7 @@
namePart = new AssignNode(this.name, literal("" + svar + "[" + ivar + "]")).compile(merge(o, {
indent: this.idt(1),
top: true
})) + "\n";
})) + '\n';
} else {
if (name) {
namePart = ("" + name + " = " + svar + "[" + ivar + "]");
@ -1504,9 +1504,7 @@
}
body = ClosureNode.wrap(body, true);
} else {
if (namePart) {
varPart = ("" + (this.idt(1)) + namePart + ";\n");
}
varPart = this.pattern ? namePart : ("" + (this.idt(1)) + namePart + ";\n");
}
this.object ? (forPart = ("" + ivar + " in " + svar + ") { if (" + (utility('hasProp')) + ".call(" + svar + ", " + ivar + ")")) : null;
body = body.compile(merge(o, {

View file

@ -1247,7 +1247,7 @@ exports.ForNode: class ForNode extends BaseNode
svar: scope.freeVariable()
sourcePart: "$svar = ${ @source.compile(o) };"
if @pattern
namePart: new AssignNode(@name, literal("$svar[$ivar]")).compile(merge o, {indent: @idt(1), top: true}) + "\n"
namePart: new AssignNode(@name, literal("$svar[$ivar]")).compile(merge o, {indent: @idt(1), top: true}) + '\n'
else
namePart: "$name = $svar[$ivar]" if name
unless @object
@ -1266,7 +1266,7 @@ exports.ForNode: class ForNode extends BaseNode
body.unshift literal "var $index = $ivar" if index
body: ClosureNode.wrap(body, true)
else
varPart: "${@idt(1)}$namePart;\n" if namePart
varPart: if @pattern then namePart else "${@idt(1)}$namePart;\n"
if @object
forPart: "$ivar in $svar) { if (${utility('hasProp')}.call($svar, $ivar)"
body: body.compile(merge(o, {indent: @idt(1), top: true}))