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

Generic converter with no generic param doesn't compile when there is another generic converter with the same name #2869

Open
adrian-budau opened this issue Jun 4, 2015 · 2 comments

Comments

@adrian-budau
Copy link

Found it pretty hard to define this, I think it's better explained with an example

type nim
  TT[T] = object

converter conv[T](x: int): TT[T] =
  discard

# comment the following two lines and the program will compile
converter conv[T](n: seq[T]): seq[seq[T]] =
  discard

var x = conv[int](0)

This one gives an error that the first converter can not be instantiated with type T.

If I change the converters to procs, then the error also goes away.

@dom96 dom96 added the Generics label Jun 4, 2015
@Araq Araq added Converters and removed Generics labels Aug 26, 2016
@Araq
Copy link
Member

Araq commented May 22, 2019

Still an issue.

@metagn
Copy link
Collaborator

metagn commented Jan 18, 2025

type
  TT[T] = object

converter conv[T](x: int): TT[T] =
  discard

proc foo(n: string) =
  discard

foo(0)

Gives same error without the same name or explicit instantiation, but maybe the original issue can be worked around by not allowing converter matches in converter calls.

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

4 participants