Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docstring comes out in expansion of defmacro! #1424

Closed
gilch opened this issue Sep 16, 2017 · 1 comment · Fixed by #1952
Closed

Docstring comes out in expansion of defmacro! #1424

gilch opened this issue Sep 16, 2017 · 1 comment · Fixed by #1952
Labels

Comments

@gilch
Copy link
Member

gilch commented Sep 16, 2017

Macros defined with defmacro! put too much in the expansion. This isn't obvious unless you have --spy on or use disassemble. I also see a lot of Nones for some reason. It seems to be the result of each form in the defmacro! definition, instead of just the final one.

=> (defmacro! foo [] "doc" 42)
from hy.core.language import interleave
import hy
from hy import HyExpression, HySymbol

def _hy_anon_fn_1():
    None
    return HyExpression(((([] + [HySymbol('do')]) + [HyExpression((([] + [HySymbol('setv')]) + list((interleave([], []) or []))))]) + list((['doc', 42] or []))))
hy.macros.macro('foo')(_hy_anon_fn_1)
<function _hy_anon_fn_1 at 0x000001E6E05F4F28>
=> (foo)
None
'doc'
42
42
=> (disassemble '(foo))
from hy.core.language import disassemble
from hy import HyExpression, HySymbol
disassemble(HyExpression(([] + [HySymbol('foo')])))
"Module(body=[Expr(value=Name(id='None')), Expr(value=Str(s='doc')), Expr(value=Num(n=42))])"
@gilch
Copy link
Member Author

gilch commented Apr 30, 2018

I suspect this is due to a compiler mutation #1542.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant