replace old problematic isNamedTuple implementation by TypeTrait isNamedTuple in dollars.nim (#13347)
* replace old problematic isNamedTuple implementation by TypeTrait isNamedTuple * fix for bootstrap
This commit is contained in:
parent
abd660c407
commit
c0a2e2ed92
2 changed files with 16 additions and 11 deletions
|
|
@ -103,6 +103,7 @@ proc initDefines*(symbols: StringTableRef) =
|
||||||
defineSymbol("nimNewShiftOps")
|
defineSymbol("nimNewShiftOps")
|
||||||
defineSymbol("nimHasCursor")
|
defineSymbol("nimHasCursor")
|
||||||
defineSymbol("nimHasExceptionsQuery")
|
defineSymbol("nimHasExceptionsQuery")
|
||||||
|
defineSymbol("nimHasIsNamedTuple")
|
||||||
|
|
||||||
when defined(nimHasLibFFI):
|
when defined(nimHasLibFFI):
|
||||||
# Renaming as we can't conflate input vs output define flags; e.g. this
|
# Renaming as we can't conflate input vs output define flags; e.g. this
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,10 @@ proc `$`*(t: typedesc): string {.magic: "TypeTrait".}
|
||||||
## doAssert $(type("Foo")) == "string"
|
## doAssert $(type("Foo")) == "string"
|
||||||
## static: doAssert $(type(@['A', 'B'])) == "seq[char]"
|
## static: doAssert $(type(@['A', 'B'])) == "seq[char]"
|
||||||
|
|
||||||
|
when defined(nimHasIsNamedTuple):
|
||||||
|
proc isNamedTuple(T: typedesc): bool {.magic: "TypeTrait".}
|
||||||
|
else:
|
||||||
|
# for bootstrap; remove after release 1.2
|
||||||
proc isNamedTuple(T: typedesc): bool =
|
proc isNamedTuple(T: typedesc): bool =
|
||||||
# Taken from typetraits.
|
# Taken from typetraits.
|
||||||
when T isnot tuple: result = false
|
when T isnot tuple: result = false
|
||||||
|
|
@ -62,6 +65,7 @@ proc isNamedTuple(T: typedesc): bool =
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
||||||
proc `$`*[T: tuple|object](x: T): string =
|
proc `$`*[T: tuple|object](x: T): string =
|
||||||
## Generic ``$`` operator for tuples that is lifted from the components
|
## Generic ``$`` operator for tuples that is lifted from the components
|
||||||
## of `x`. Example:
|
## of `x`. Example:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue