mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-15 01:38:13 -05:00
fixed a bug where multiple trailing comments prevented returnification
This commit is contained in:
@@ -197,11 +197,11 @@
|
|||||||
};
|
};
|
||||||
Expressions.prototype.makeReturn = function() {
|
Expressions.prototype.makeReturn = function() {
|
||||||
var end, idx;
|
var end, idx;
|
||||||
end = this.expressions[idx = this.expressions.length - 1];
|
idx = this.expressions.length;
|
||||||
if (end instanceof Comment) {
|
while ((end = this.expressions[--idx]) instanceof Comment) {
|
||||||
end = this.expressions[idx -= 1];
|
|
||||||
}
|
}
|
||||||
if (end && !(end instanceof Return)) {
|
if (end) {
|
||||||
this.expressions[idx] = end.makeReturn();
|
this.expressions[idx] = end.makeReturn();
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -195,10 +195,9 @@ exports.Expressions = class Expressions extends Base
|
|||||||
# An Expressions node does not return its entire body, rather it
|
# An Expressions node does not return its entire body, rather it
|
||||||
# ensures that the final expression is returned.
|
# ensures that the final expression is returned.
|
||||||
makeReturn: ->
|
makeReturn: ->
|
||||||
end = @expressions[idx = @expressions.length - 1]
|
idx = @expressions.length
|
||||||
end = @expressions[idx -= 1] if end instanceof Comment
|
while (end = @expressions[--idx]) instanceof Comment then
|
||||||
if end and end not instanceof Return
|
@expressions[idx] = end.makeReturn() if end
|
||||||
@expressions[idx] = end.makeReturn()
|
|
||||||
this
|
this
|
||||||
|
|
||||||
# An **Expressions** is the only node that can serve as the root.
|
# An **Expressions** is the only node that can serve as the root.
|
||||||
|
|||||||
Reference in New Issue
Block a user