* fixes #20155; repr range with distinct types is broken with ORC * skipRanges
This commit is contained in:
parent
9b9f24f01b
commit
37b3f62eef
3 changed files with 10 additions and 1 deletions
|
|
@ -190,6 +190,9 @@ proc evalTypeTrait(c: PContext; traitCall: PNode, operand: PType, context: PSym)
|
||||||
arg = arg.base.skipTypes(skippedTypes + {tyGenericInst})
|
arg = arg.base.skipTypes(skippedTypes + {tyGenericInst})
|
||||||
if not rec: break
|
if not rec: break
|
||||||
result = getTypeDescNode(c, arg, operand.owner, traitCall.info)
|
result = getTypeDescNode(c, arg, operand.owner, traitCall.info)
|
||||||
|
of "skipRanges":
|
||||||
|
var arg = operand.skipTypes({tyRange})
|
||||||
|
result = getTypeDescNode(c, arg, operand.owner, traitCall.info)
|
||||||
else:
|
else:
|
||||||
localError(c.config, traitCall.info, "unknown trait: " & s)
|
localError(c.config, traitCall.info, "unknown trait: " & s)
|
||||||
result = newNodeI(nkEmpty, traitCall.info)
|
result = newNodeI(nkEmpty, traitCall.info)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ proc isNamedTuple(T: typedesc): bool {.magic: "TypeTrait".}
|
||||||
proc distinctBase(T: typedesc, recursive: static bool = true): typedesc {.magic: "TypeTrait".}
|
proc distinctBase(T: typedesc, recursive: static bool = true): typedesc {.magic: "TypeTrait".}
|
||||||
## imported from typetraits
|
## imported from typetraits
|
||||||
|
|
||||||
|
proc skipRanges(T: typedesc): typedesc {.magic: "TypeTrait".}
|
||||||
|
|
||||||
proc repr*(x: NimNode): string {.magic: "Repr", noSideEffect.}
|
proc repr*(x: NimNode): string {.magic: "Repr", noSideEffect.}
|
||||||
|
|
||||||
proc repr*(x: int): string =
|
proc repr*(x: int): string =
|
||||||
|
|
@ -96,7 +98,10 @@ proc repr*(p: proc): string =
|
||||||
repr(cast[ptr pointer](unsafeAddr p)[])
|
repr(cast[ptr pointer](unsafeAddr p)[])
|
||||||
|
|
||||||
template repr*(x: distinct): string =
|
template repr*(x: distinct): string =
|
||||||
repr(distinctBase(typeof(x))(x))
|
when x is range: # hacks for ranges with distinct sub types
|
||||||
|
repr(distinctBase(skipRanges(typeof(x)))(x))
|
||||||
|
else:
|
||||||
|
repr(distinctBase(typeof(x))(x))
|
||||||
|
|
||||||
template repr*(t: typedesc): string = $t
|
template repr*(t: typedesc): string = $t
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
|
matrix: "--mm:refc; --mm:orc"
|
||||||
output: '''[1, 0, 0, 0, 0, 0, 0, 0] CTBool[Ct[system.uint32]]'''
|
output: '''[1, 0, 0, 0, 0, 0, 0, 0] CTBool[Ct[system.uint32]]'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue