forked from ceridwen/macropy
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
These expand differently:
from macropy.core import macros, show_expanded
from unpythonic.syntax import macros, curry
with curry, show_expanded:
def add3(a, b, c):
return a + b + c
assert add3(1)(2)(3) == 6
with show_expanded:
with curry:
def add3(a, b, c):
return a + b + c
assert add3(1)(2)(3) == 6I traced this and the issue is triggered by the fact that from the viewpoint of macropy.core.macros.Block.detect_macro, curry doesn't only update the existing nodes in in_tree.body, but replaces the body with something else, when it wraps the original tree in a with dyn.let(...):.
If the macros are invoked in the same with, this new tree is never seen by show_expanded - it gets just the updated nodes of the original in_tree.body.
Using nested with blocks (and keeping in mind the from inside out expansion order), the expansion works as expected - show_expanded sees the with dyn.let(...): inserted by curry.
It seems this can be fixed very simply - PR to follow.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels