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

Attaching a macro to an iterator cannot fill the body #16413

Closed
codehz opened this issue Dec 20, 2020 · 0 comments · Fixed by #24440
Closed

Attaching a macro to an iterator cannot fill the body #16413

codehz opened this issue Dec 20, 2020 · 0 comments · Fixed by #24440

Comments

@codehz
Copy link
Contributor

codehz commented Dec 20, 2020

Example

import macros

macro identity(x: untyped) =
  result = x.copy()
  result[6] = quote do:
    yield 1
  echo result.toStrLit

iterator demo(): int {.identity.}
iterator demo2(): int {.identity.} = discard # but this works as expected

Current Output

Hint: used config file '/playground/nim/config/nim.cfg' [Conf]
Hint: used config file '/playground/nim/config/config.nims' [Conf]
.....
iterator demo(): int =
  yield 1

/usercode/in.nim(9, 1) Error: implementation of 'demo' expected

Expected Output

no error

Additional Information

https://play.nim-lang.org/#ix=2IQF

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

Successfully merging a pull request may close this issue.

1 participant