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

explicit generic instantiation accepts value when type is expected #12664

Open
timotheecour opened this issue Nov 15, 2019 · 1 comment
Open

Comments

@timotheecour
Copy link
Member

explicit template instantiation accepts value when type is expected

Example

type A[T] = object # ditto with A[T: string]
let a1 = A[string]() # ok
let a2 = A["abc"]() # should not compile
static: doAssert type(a1) is type(a2)

type B[T: static string] = object
let b2 = B["abc"]() # ok

Current Output

compiles

Expected Output

CT error: expected type, got value

Additional Information

latest devel f22d3c7

@timotheecour timotheecour changed the title explicit template instantiation accepts value when type is expected explicit generic instantiation accepts value when type is expected Feb 18, 2020
@metagn
Copy link
Collaborator

metagn commented Aug 21, 2023

type A[T] = object
let a2 = A["abc"]()

No reason this shouldn't compile.

# ditto with A[T: string]

This is a bug. Keywords for search: generic parameter type constraint

Also, generics are mistakenly referred to as templates again.

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

3 participants