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

Error: cannot instantiate K got: <T> but expected: <T> with generics and template #21346

Closed
tersec opened this issue Feb 10, 2023 · 0 comments · Fixed by #24119
Closed

Error: cannot instantiate K got: <T> but expected: <T> with generics and template #21346

tersec opened this issue Feb 10, 2023 · 0 comments · Fixed by #24119

Comments

@tersec
Copy link
Contributor

tersec commented Feb 10, 2023

Description

type K[T] = object
template s[T](x: int) = discard
proc b1(n: bool | bool) = s[K[K[int]]](3)
proc b2(n: bool)        = s[K[K[int]]](3)
b1(false)     # Error: cannot instantiate K; got: <T> but expected: <T>
b2(false)     # Builds, on its own

Nim Version

Released stable version:

Nim Compiler Version 1.6.10 [Linux: amd64]
Compiled at 2022-11-23
Copyright (c) 2006-2021 by Andreas Rumpf

active boot switches: -d:release

From version-1-6:

Nim Compiler Version 1.6.11 [Linux: amd64]
Compiled at 2023-02-09
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 7f90bcf5b4cbe5b7da534dd79bafbb4cafb313fa
active boot switches: -d:release

devel:

Nim Compiler Version 1.9.1 [Linux: amd64]
Compiled at 2023-02-09
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 642136ec4f2cd93cdd753bf16fa4aec89b8fee82
active boot switches: -d:release

version-2-0:

Nim Compiler Version 1.9.1 [Linux: amd64]
Compiled at 2023-02-09
Copyright (c) 2006-2022 by Andreas Rumpf

git hash: 414f36980f17ee80a48b2f38e035b7e94f2112bd
active boot switches: -d:release

Current Output

/tmp/repro.nim(5, 3) template/generic instantiation of `b1` from here
/tmp/repro.nim(3, 30) Error: cannot instantiate K [type declared in /tmp/repro.nim(1, 6)]
got: <T>
but expected: <T>

Expected Output

Successful build, or at least consistency between generic b1 and non-generic b2 procs both taking same types.

Possible Solution

No response

Additional Information

No response

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

Successfully merging a pull request may close this issue.

2 participants