Skip to content

Commit

Permalink
replace old problematic isNamedTuple implementation by TypeTrait isNa…
Browse files Browse the repository at this point in the history
…medTuple
  • Loading branch information
timotheecour committed Feb 7, 2020
1 parent c877961 commit 3b3b116
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions lib/system/dollars.nim
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,7 @@ proc `$`*(t: typedesc): string {.magic: "TypeTrait".}
## doAssert $(type("Foo")) == "string"
## static: doAssert $(type(@['A', 'B'])) == "seq[char]"


proc isNamedTuple(T: typedesc): bool =
# Taken from typetraits.
when T isnot tuple: result = false
else:
var t: T
for name, _ in t.fieldPairs:
when name == "Field0":
return compiles(t.Field0)
else:
return true
return false
proc isNamedTuple(T: typedesc): bool {.magic: "TypeTrait".}

proc `$`*[T: tuple|object](x: T): string =
## Generic ``$`` operator for tuples that is lifted from the components
Expand Down

0 comments on commit 3b3b116

Please sign in to comment.