Skip to content

issues using generic parameters in template #6340

@jcosborn

Description

@jcosborn

In template fooT[T](x: A[T]) calling foo(T), which is a proc, crashes the compiler and calling fooT(T), which is a template, matches the int overload instead of typedesc[int].

type
  A[T] = object
    v: T

proc foo(x: int) = echo "int"
proc foo(x: typedesc[int]) = echo "typedesc[int]"
template fooT(x: int) = echo "int"
template fooT(x: typedesc[int]) = echo "typedesc[int]"

proc foo[T](x: A[T]) =
  foo(T)   # typedesc[int]  (correct)
  fooT(T)  # typedesc[int]  (correct)

template fooT[T](x: A[T]) =
  foo(T)   # typedescparam.nim(20, 5) Error: internal error: expr(skType); unknown symbol
  fooT(T)  # int  (should be typedesc[int])

var x: A[int]
foo(x)
fooT(x)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions