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

Make the proc with iterator parameter overloadable #14148

Open
slangmgh opened this issue Apr 28, 2020 · 0 comments
Open

Make the proc with iterator parameter overloadable #14148

slangmgh opened this issue Apr 28, 2020 · 0 comments

Comments

@slangmgh
Copy link
Contributor

slangmgh commented Apr 28, 2020

If there is a macro accept an iterator parameter, it will no compile if there is same name proc with other typed parameter, that's very annoying, toSeq has this problem.

Compile the following code will generate error.

import macros

# comment this proc will make the compiler works
proc p1(x: int) =  echo x

macro p1(s: untyped): untyped =
   quote do:
      for n in `s`:
         echo n

iterator it(): int =
   yield 1; yield 2

p1(it())

Compiler output:

D:\Work\Nim\dd.nim(14, 6) Error: attempting to call routine: 'it'
  found 'dd.it() [declared in D:\Work\Stock\dd.nim(11, 10)]' of kind 'iterator'
@slangmgh slangmgh changed the title Make the iterator parameter overloadable Make the proc with iterator parameter overloadable Apr 28, 2020
@timotheecour timotheecour mentioned this issue Feb 27, 2021
8 tasks
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

No branches or pull requests

1 participant