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

View File

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