Open
Description
import typetraits
when defined(case_ok):
# ok
block:
type seq2[T] = (T,int)
echo seq2[int].T
doAssert seq2[int].T is int
block:
type seq2[T] = (T,)
echo seq2[int].T
block:
type seq2[T] = int
echo seq2[int].T
block:
type seq2[T] = object
discard
echo seq2[int].T
when defined(case2):
type seq2[T] = T
# Error: undeclared field: 'T'
echo seq2[int].T
when defined(case_seq):
# Error: undeclared field: 'T'
echo seq[int].T
this breaks generic code and user defined concepts isSeq
that check whether some type is a seq[T] for some T
- likewise for other
magic
types in system.nim
NOTE: this should be feasible according to (my interpretation of) docs:
Procs written with the implicitly generic style will often need to refer to the type parameters of the matched generic type. They can be easily accessed using the dot syntax:
type Matrix[T, Rows, Columns] = object
proc[]
(m: Matrix, row, col: int): Matrix.T =
in any case it's useful