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
The code:
template seqType(t: typedesc): typedesc = when t is int: seq[int] else: seq[string] proc mkSeq[T: int|string](v: T): seqType(T) = result = newSeq[T](1) result[0] = v echo mkSeq("a") # Fails here echo mkSeq(1)
fails to compile with the message:
typetest.nim(13, 11) template/generic instantiation from here typetest.nim(8, 21) Error: type mismatch: got (seq[int]) but expected 'seq[string]'
The text was updated successfully, but these errors were encountered:
The problem is that t is tyTypeDesc(tyGenericParam T) here: https://github.com/nim-lang/Nim/blob/devel/compiler/vm.nim#L1083. That's why VM chooses else branch
t
tyTypeDesc(tyGenericParam T)
else
Sorry, something went wrong.
69ea133
zah
metagn
Successfully merging a pull request may close this issue.
The code:
fails to compile with the message:
The text was updated successfully, but these errors were encountered: