We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Learn more about funding links in repositories.
Report abuse
1 parent f8d7d1d commit bbb3551Copy full SHA for bbb3551
lib/opal/nodes/yield.rb
@@ -4,7 +4,10 @@ module Opal
4
module Nodes
5
class BaseYieldNode < Base
6
def compile_call(children, level)
7
- scope.uses_block!
+ yielding_scope = find_yielding_scope
8
+
9
+ yielding_scope.uses_block!
10
+ block_name = yielding_scope.block_name || '$yield'
11
12
if yields_single_arg?(children)
13
push expr(children.first)
@@ -20,8 +23,16 @@ def compile_call(children, level)
20
23
end
21
24
22
25
- def block_name
- scope.block_name || '$yield'
26
+ def find_yielding_scope
27
+ working = scope
28
+ while working
29
+ if working.block_name or working.def?
30
+ break
31
+ end
32
+ working = working.parent
33
34
35
+ working
36
37
38
def yields_single_arg?(children)
0 commit comments