We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Discussing the snippet below on #nim it was suggested this was worth filing an issue.
My expectation was that it would be fine to do this:
import strutils proc parse[T: int](s: string): T = parseInt(s) proc parse[T: float](s: string): T = parseFloat(s) proc parse[T: bool](s: string): T = parseBool(s)
as long as the caller is explicitly matching one of the signatures like so:
let a parse[int]("42")
However, compilation fails with:
# /tmp/t.nim(4, 6) Error: overloaded 'parse' leads to ambiguous calls
Are my expectations wrong, and if so, which part of the manual did I not read well enough?
The suggestion "Don't do that; it's stupid" also has come up, which I would also take for an answer.
The text was updated successfully, but these errors were encountered:
It's just a compiler bug, nothing wrong with the code.
Sorry, something went wrong.
or
when true: proc fn[T: int](): T = discard proc fn[T: bool](): T = discard
=> Error: overloaded 'fn' leads to ambiguous calls
when true: proc fn[T: int](a: T): T = discard proc fn[T: bool](a: T): T = discard
when true: proc fn(T: typedesc[int]): T = discard proc fn(T: typedesc[bool]): T = discard
refs nim-lang/RFCs#40
The problem is in searchForProc, it thinks it's redefining the other parse procs because it doesn't check if the generic params are different
searchForProc
parse
No branches or pull requests
Discussing the snippet below on #nim it was suggested this was worth filing an issue.
My expectation was that it would be fine to do this:
as long as the caller is explicitly matching one of the signatures like so:
However, compilation fails with:
Are my expectations wrong, and if so, which part of the manual did I not read well enough?
The suggestion "Don't do that; it's stupid" also has come up, which I would also take for an answer.
The text was updated successfully, but these errors were encountered: