mirror of
				https://github.com/jashkenas/coffeescript.git
				synced 2022-11-09 12:23:24 -05:00 
			
		
		
		
	reinstating makeReturn for statement literals.
This commit is contained in:
		
							parent
							
								
									dbeb626f32
								
							
						
					
					
						commit
						2ec1c3b56c
					
				
					 3 changed files with 17 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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, '
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue