* fix typetraits.`$` regression https://github.com/c-blake/cligen/issues/84
* add test
This commit is contained in:
Timothee Cour
2018-12-30 00:40:21 -08:00
committed by Andreas Rumpf
parent aadbdd6b06
commit a6633b9658
3 changed files with 8 additions and 2 deletions

View File

@@ -129,7 +129,8 @@ proc evalTypeTrait(c: PContext; traitCall: PNode, operand: PType, context: PSym)
template typeWithSonsResult(kind, sons): PNode =
newTypeWithSons(context, kind, sons).toNode(traitCall.info)
case trait.sym.name.s
let s = trait.sym.name.s
case s
of "or", "|":
return typeWithSonsResult(tyOr, @[operand, operand2])
of "and":
@@ -160,7 +161,7 @@ proc evalTypeTrait(c: PContext; traitCall: PNode, operand: PType, context: PSym)
hasDestructor(t)
result = newIntNodeT(ord(not complexObj), traitCall, c.graph)
else:
localError(c.config, traitCall.info, "unknown trait")
localError(c.config, traitCall.info, "unknown trait: " & s)
result = newNodeI(nkEmpty, traitCall.info)
proc semTypeTraits(c: PContext, n: PNode): PNode =

View File

@@ -10,6 +10,8 @@
## This module defines compile-time reflection procs for
## working with types
export system.`$`
proc name*(t: typedesc): string {.magic: "TypeTrait".}
## Alias for system.`$`(t) since Nim v0.20.0.

View File

@@ -0,0 +1,3 @@
# todo: merge with $nimc_D/tests/metatype/ttypetraits.nim (currently disabled)
from typetraits import `$` # checks fix for https://github.com/c-blake/cligen/issues/84