fix incorrect lenTuple implementation (#13423)
This commit is contained in:
parent
d1f9f11245
commit
273a93581f
3 changed files with 48 additions and 11 deletions
|
|
@ -71,15 +71,14 @@ proc distinctBase*(T: typedesc): typedesc {.magic: "TypeTrait".}
|
|||
## Returns base type for distinct types, works only for distinct types.
|
||||
## compile time error otherwise
|
||||
|
||||
import std/macros
|
||||
|
||||
macro lenTuple*(t: tuple): int {.since: (1, 1).} =
|
||||
## Return number of elements of `t`
|
||||
newLit t.len
|
||||
|
||||
macro lenTuple*(t: typedesc[tuple]): int {.since: (1, 1).} =
|
||||
proc lenTuple*(T: typedesc[tuple]): int {.magic: "TypeTrait", since: (1, 1).}
|
||||
## Return number of elements of `T`
|
||||
newLit t.len
|
||||
|
||||
since (1, 1):
|
||||
template lenTuple*(t: tuple): int =
|
||||
## Return number of elements of `t`
|
||||
lenTuple(type(t))
|
||||
|
||||
since (1, 1):
|
||||
template get*(T: typedesc[tuple], i: static int): untyped =
|
||||
|
|
@ -87,6 +86,8 @@ since (1, 1):
|
|||
# Note: `[]` currently gives: `Error: no generic parameters allowed for ...`
|
||||
type(default(T)[i])
|
||||
|
||||
import std/macros
|
||||
|
||||
macro genericParams*(T: typedesc): untyped {.since: (1, 1).} =
|
||||
## return tuple of generic params for generic `T`
|
||||
runnableExamples:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue