|
20 | 20 | from macropy.core.hquotes import macros, hq |
21 | 21 | from macropy.core.walkers import Walker |
22 | 22 |
|
23 | | -from .util import isx, isec, \ |
| 23 | +from .util import isx, make_isxpred, isec, \ |
24 | 24 | detect_callec, detect_lambda, \ |
25 | 25 | has_tco, sort_lambda_decorators, \ |
26 | 26 | suggest_decorator_index |
|
29 | 29 |
|
30 | 30 | from ..dynassign import dyn |
31 | 31 | from ..it import uniqify |
32 | | -from ..fun import identity |
| 32 | +from ..fun import identity, orf |
33 | 33 | from ..tco import trampolined, jump |
34 | 34 | from ..lazyutil import mark_lazy |
35 | 35 |
|
@@ -557,6 +557,7 @@ def _tco_transform_lambda(tree, *, preproc_cb, userlambdas, known_ecs, transform |
557 | 557 |
|
558 | 558 | # Tail-position analysis for a return-value expression (also the body of a lambda). |
559 | 559 | # Here we need to be very, very selective about where to recurse so this is not a Walker. |
| 560 | +_isjump = orf(make_isxpred("jump"), make_isxpred("loop")) |
560 | 561 | def _transform_retexpr(tree, known_ecs, call_cb=None, data_cb=None): |
561 | 562 | """Analyze and TCO a return-value expression or a lambda body. |
562 | 563 |
|
@@ -607,7 +608,7 @@ def transform(tree): |
607 | 608 | # - Hence, transform_return() calls us on the content of |
608 | 609 | # all ec nodes directly. ec(...) is like return; the |
609 | 610 | # argument is the retexpr. |
610 | | - if not (isx(tree.func, "jump") or isx(tree.func, "loop") or isec(tree, known_ecs)): |
| 611 | + if not (isx(tree.func, _isjump) or isec(tree, known_ecs)): |
611 | 612 | tree.args = [tree.func] + tree.args |
612 | 613 | tree.func = hq[jump] |
613 | 614 | tree = transform_call(tree) |
|
0 commit comments