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

untyped param: wrong error message (undeclared identifier) on type mismatch of another param #12019

Closed
mratsim opened this issue Aug 23, 2019 · 2 comments

Comments

@mratsim
Copy link
Collaborator

mratsim commented Aug 23, 2019

A macro with a mix of untyped arguments and generic arguments will display "undeclared identifier" instead of type mismatch if the generic semcheck fails.

Test case

import macros

macro forEach*(
        idx: untyped,
        s: Slice,
        funcCall: untyped{call}
      ): untyped =

  echo getTypeInst(s).treerepr


proc foo(i: int) =
  echo i

forEach(i, 0..2, foo(i))     # works
forEach(i, 0'u..2'u, foo(i)) # works
forEach(i, 0'u..2, foo(i))   # Error: undeclared identifier: 'i' // expected type mismatch
forEach(i, 0..2'u, foo(i))   # Error: undeclared identifier: 'i' // expected type mismatch

Seems linked to #8677

@timotheecour
Copy link
Member

@mratsim the issue is not with macros nor generics, it's with untyped; maybe change the title?

template fun1(x1: untyped, x2: int) = discard
fun1(nonexistant, 2)
fun1(nonexistant, 2.1)  # Error: undeclared identifier: 'nonexistant'

(from timotheecour#23)

@mratsim mratsim changed the title Macros + Generics: wrong error message (undeclared identifier) on type mismatch untyped: wrong error message (undeclared identifier) on type mismatch of another param Aug 24, 2019
@mratsim mratsim changed the title untyped: wrong error message (undeclared identifier) on type mismatch of another param untyped param: wrong error message (undeclared identifier) on type mismatch of another param Aug 24, 2019
@timotheecour
Copy link
Member

timotheecour commented Nov 13, 2020

closing as duplicate of #14827

closing as duplicate of #9620

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

No branches or pull requests

2 participants