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

Type mismatch on specialized alias type and template #13799

Closed
arnetheduck opened this issue Mar 29, 2020 · 0 comments · Fixed by #24119
Closed

Type mismatch on specialized alias type and template #13799

arnetheduck opened this issue Mar 29, 2020 · 0 comments · Fixed by #24119

Comments

@arnetheduck
Copy link
Contributor

type
  X[A, B] = object
    a: A
    b: B

  Y[A] = X[A, int]

template s(T: type X): X = T()

template t[A, B](T: type X[A, B]): X[A, B] = T()

proc works1(): Y[int] = s(X[int, int])
proc works2(): Y[int] = t(X[int, int])
proc works3(): Y[int] = t(Y[int])

proc broken(): Y[int] = s(Y[int])
/home/arnetheduck/status/nim-beacon-chain/vendor/nim-eth/eth/keys/test.nim(16, 26) Error: type mismatch: got <type Y[system.int]>
but expected one of: 
template s(T: type X): X
  first type mismatch at position: 1
  required type for T: type X
  but expression 'Y[int]' is of type: type Y[system.int]
Nim Compiler Version 1.1.1 [Linux: amd64]
Compiled at 2020-03-29
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: 8c719fce54544c8d14ce7c0e4639c974c1748668
active boot switches: -d:release
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