reinstating makeReturn for statement literals.

This commit is contained in:
Jeremy Ashkenas 2010-12-23 10:09:05 -08:00
parent dbeb626f32
commit 2ec1c3b56c
3 changed files with 17 additions and 2 deletions

View File

@ -320,7 +320,11 @@
this.value = value;
}
Literal.prototype.makeReturn = function() {
return new Return(this);
if (this.isStatement()) {
return this;
} else {
return new Return(this);
}
};
Literal.prototype.isAssignable = function() {
return IDENTIFIER.test(this.value);

View File

@ -271,7 +271,7 @@ exports.Literal = class Literal extends Base
constructor: (@value) ->
makeReturn: ->
new Return this
if @isStatement() then this else new Return this
isAssignable: ->
IDENTIFIER.test @value

View File

@ -90,3 +90,14 @@ obj = {
}
ok obj.func(yes) is 101
# Switch with break as the return value of a loop.
i = 10
results = while i > 0
i--
switch i % 2
when 1 then i
when 0 then break
eq results.join(', '), '9, , 7, , 5, , 3, , 1, '