mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 19:34:27 -05:00
fixing infinite recursion when compiling if statements containing pure_statements
This commit is contained in:
@@ -69,7 +69,9 @@
|
|||||||
del(this.options, 'operation');
|
del(this.options, 'operation');
|
||||||
}
|
}
|
||||||
top = this.top_sensitive() ? this.options.top : del(this.options, 'top');
|
top = this.top_sensitive() ? this.options.top : del(this.options, 'top');
|
||||||
closure = this.is_statement() && !this.is_pure_statement() && !top && !this.options.returns && !(this instanceof CommentNode);
|
closure = this.is_statement() && !this.is_pure_statement() && !top && !this.options.returns && !(this instanceof CommentNode) && !(this.contains(function(n) {
|
||||||
|
return n.is_pure_statement();
|
||||||
|
}));
|
||||||
return closure ? this.compile_closure(this.options) : this.compile_node(this.options);
|
return closure ? this.compile_closure(this.options) : this.compile_node(this.options);
|
||||||
};
|
};
|
||||||
// Statements converted into expressions via closure-wrapping share a scope
|
// Statements converted into expressions via closure-wrapping share a scope
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ exports.BaseNode: class BaseNode
|
|||||||
del @options, 'operation' unless this instanceof ValueNode
|
del @options, 'operation' unless this instanceof ValueNode
|
||||||
top: if @top_sensitive() then @options.top else del @options, 'top'
|
top: if @top_sensitive() then @options.top else del @options, 'top'
|
||||||
closure: @is_statement() and not @is_pure_statement() and not top and
|
closure: @is_statement() and not @is_pure_statement() and not top and
|
||||||
not @options.returns and not (this instanceof CommentNode)
|
not @options.returns and not (this instanceof CommentNode) and
|
||||||
|
not (@contains (n) -> n.is_pure_statement())
|
||||||
if closure then @compile_closure(@options) else @compile_node(@options)
|
if closure then @compile_closure(@options) else @compile_node(@options)
|
||||||
|
|
||||||
# Statements converted into expressions via closure-wrapping share a scope
|
# Statements converted into expressions via closure-wrapping share a scope
|
||||||
@@ -549,7 +550,7 @@ exports.ArrayNode: class ArrayNode extends BaseNode
|
|||||||
constructor: (objects) ->
|
constructor: (objects) ->
|
||||||
@children: @objects: objects or []
|
@children: @objects: objects or []
|
||||||
@compile_splat_literal: SplatNode.compile_mixed_array <- @, @objects
|
@compile_splat_literal: SplatNode.compile_mixed_array <- @, @objects
|
||||||
|
|
||||||
compile_node: (o) ->
|
compile_node: (o) ->
|
||||||
o.indent: @idt(1)
|
o.indent: @idt(1)
|
||||||
objects: []
|
objects: []
|
||||||
@@ -800,7 +801,7 @@ exports.SplatNode: class SplatNode extends BaseNode
|
|||||||
compile_value: (o, name, index) ->
|
compile_value: (o, name, index) ->
|
||||||
"Array.prototype.slice.call($name, $index)"
|
"Array.prototype.slice.call($name, $index)"
|
||||||
|
|
||||||
# Utility function that converts arbitrary number of elements, mixed with
|
# Utility function that converts arbitrary number of elements, mixed with
|
||||||
# splats, to a proper array
|
# splats, to a proper array
|
||||||
SplatNode.compile_mixed_array: (list, o) ->
|
SplatNode.compile_mixed_array: (list, o) ->
|
||||||
args: []
|
args: []
|
||||||
|
|||||||
Reference in New Issue
Block a user