mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
fix typetraits.$ regression https://github.com/c-blake/cligen/issues/84 (#10131)
* fix typetraits.`$` regression https://github.com/c-blake/cligen/issues/84 * add test
This commit is contained in:
committed by
Andreas Rumpf
parent
aadbdd6b06
commit
a6633b9658
@@ -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 =
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
3
tests/metatype/ttypetraits2.nim
Normal file
3
tests/metatype/ttypetraits2.nim
Normal 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
|
||||
Reference in New Issue
Block a user