summary refs log tree commit diff stats
path: root/lib/system/repr_v2.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2022-09-12 04:55:22 +0800
committerGitHub <noreply@github.com>2022-09-11 16:55:22 -0400
commit37b3f62eef16b0e7cb89e18f9ddc1fb96e17fb1b (patch)
tree4b111a131c91de505ee3750884bac5aa09b7556e /lib/system/repr_v2.nim
parent9b9f24f01bb373362b476a0754a5de95bd108d76 (diff)
downloadNim-37b3f62eef16b0e7cb89e18f9ddc1fb96e17fb1b.tar.gz
fixes #20155; repr range with distinct types is broken with ORC (#20158)
* fixes #20155; repr range with distinct types is broken with ORC

* skipRanges
Diffstat (limited to 'lib/system/repr_v2.nim')
-rw-r--r--lib/system/repr_v2.nim7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/system/repr_v2.nim b/lib/system/repr_v2.nim
index 0e9bec0f3..d87e07b7e 100644
--- a/lib/system/repr_v2.nim
+++ b/lib/system/repr_v2.nim
@@ -9,6 +9,8 @@ proc isNamedTuple(T: typedesc): bool {.magic: "TypeTrait".}
 proc distinctBase(T: typedesc, recursive: static bool = true): typedesc {.magic: "TypeTrait".}
   ## imported from typetraits
 
+proc skipRanges(T: typedesc): typedesc {.magic: "TypeTrait".}
+
 proc repr*(x: NimNode): string {.magic: "Repr", noSideEffect.}
 
 proc repr*(x: int): string =
@@ -96,7 +98,10 @@ proc repr*(p: proc): string =
   repr(cast[ptr pointer](unsafeAddr p)[])
 
 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