Does a nested function contain a self-reference in its body? If a nested function only has references in the surrounding function, we don't need to add it to the environment.
(builder: IRBuilder, fitem: FuncItem)
| 312 | |
| 313 | |
| 314 | def has_nested_func_self_reference(builder: IRBuilder, fitem: FuncItem) -> bool: |
| 315 | """Does a nested function contain a self-reference in its body? |
| 316 | |
| 317 | If a nested function only has references in the surrounding function, |
| 318 | we don't need to add it to the environment. |
| 319 | """ |
| 320 | if any(isinstance(sym, FuncBase) for sym in builder.free_variables.get(fitem, set())): |
| 321 | return True |
| 322 | return any( |
| 323 | has_nested_func_self_reference(builder, nested) |
| 324 | for nested in builder.encapsulating_funcs.get(fitem, []) |
| 325 | ) |
| 326 | |
| 327 | |
| 328 | def gen_func_ir( |
no test coverage detected
searching dependent graphs…