@@ -130,7 +130,7 @@ def _can_be_in_region(
130130 # Check that all contents of the loop body can be part
131131 # of the region.
132132 for child in node .loop_body :
133- if not self ._can_be_in_region (child ):
133+ if not self ._can_be_in_region (child , current_block ):
134134 break
135135 else :
136136 return True
@@ -141,11 +141,12 @@ def _can_be_in_region(
141141 # of the region.
142142 allowed = True
143143 for child in node .if_body :
144- allowed = (allowed and self ._can_be_in_region (child ))
144+ allowed = (allowed and self ._can_be_in_region (child ,
145+ current_block ))
145146 if node .else_body and allowed :
146147 for child in node .else_body :
147148 allowed = (allowed and
148- self ._can_be_in_region (child ))
149+ self ._can_be_in_region (child , current_block ))
149150 return allowed
150151
151152 # All other node types we default to False.
@@ -198,16 +199,16 @@ def _compute_transformable_sections(
198199 if isinstance (child , IfBlock ):
199200 if child .else_body :
200201 else_blocks = self ._compute_transformable_sections (
201- child .else_body , trans , trans_kwargs
202+ child .else_body [:] , trans , trans_kwargs
202203 )
203204 all_blocks = else_blocks + all_blocks
204205 if_blocks = self ._compute_transformable_sections (
205- child .if_body , trans , trans_kwargs
206+ child .if_body [:] , trans , trans_kwargs
206207 )
207208 all_blocks = if_blocks + all_blocks
208209 if isinstance (child , (Loop , WhileLoop )):
209210 loop_blocks = self ._compute_transformable_sections (
210- child .loop_body , trans , trans_kwargs
211+ child .loop_body [:] , trans , trans_kwargs
211212 )
212213 all_blocks = loop_blocks + all_blocks
213214 # If any nodes are left in the current block at the end of the
@@ -247,7 +248,6 @@ def validate(self, nodes: Union[Node, Schedule, list[Node]], **kwargs):
247248 f"{ prev_position } ." )
248249 prev_position = child .position
249250
250-
251251 def _apply_transformation (self , block : list [Node ],
252252 ** kwargs ):
253253 '''
0 commit comments