typetraits: make genericHead docs reflect reality; use runnableExamples (#16776) [backport:1.4]

This commit is contained in:
Timothee Cour 2021-01-22 06:06:45 -08:00 • committed by GitHub
commit 8f1f0bd1da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 17 deletions

View file

@ -282,7 +282,12 @@ block genericHead:
doAssert not compiles(genericHead(Foo))
type Bar = object
doAssert not compiles(genericHead(Bar))
# doAssert seq[int].genericHead is seq
when false: # xxx not supported yet
doAssert seq[int].genericHead is seq
when false: # xxx not supported yet, gives: Error: identifier expected
type Hoo[T] = object
doAssert genericHead(Hoo[int])[float] is Hoo[float]
block: # elementType
iterator myiter(n: int): auto =