summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJason Beetham <beefers331@gmail.com>2024-05-23 12:15:20 -0600
committerGitHub <noreply@github.com>2024-05-23 20:15:20 +0200
commitd837d32fd571eb701b380f68c88231ff08ee124a (patch)
tree735b8cbfee53f27b56849375d2ac0f3d760fa178
parent6cd03bae2929dfd3f88008f49d0624942ef8d558 (diff)
downloadNim-d837d32fd571eb701b380f68c88231ff08ee124a.tar.gz
Skip tyAlias inside semTypeTraits in case a concept accidently emits one (#23640)
-rw-r--r--compiler/semmagic.nim2
-rw-r--r--tests/metatype/ttypetraits.nim11
2 files changed, 12 insertions, 1 deletions
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim
index 8db62a9c8..c3c032147 100644
--- a/compiler/semmagic.nim
+++ b/compiler/semmagic.nim
@@ -237,7 +237,7 @@ proc evalTypeTrait(c: PContext; traitCall: PNode, operand: PType, context: PSym)
 proc semTypeTraits(c: PContext, n: PNode): PNode =
   checkMinSonsLen(n, 2, c.config)
   let t = n[1].typ
-  internalAssert c.config, t != nil and t.kind == tyTypeDesc
+  internalAssert c.config, t != nil and t.skipTypes({tyAlias}).kind == tyTypeDesc
   if t.len > 0:
     # This is either a type known to sem or a typedesc
     # param to a regular proc (again, known at instantiation)
diff --git a/tests/metatype/ttypetraits.nim b/tests/metatype/ttypetraits.nim
index bfaa23057..6ef59bcfa 100644
--- a/tests/metatype/ttypetraits.nim
+++ b/tests/metatype/ttypetraits.nim
@@ -365,3 +365,14 @@ block: # enum.len
     doAssert MyEnum.enumLen == 4
     doAssert OtherEnum.enumLen == 3
     doAssert MyFlag.enumLen == 4
+
+when true: # Odd bug where alias can seep inside of `distinctBase`
+  import std/unittest
+
+  type
+    AdtChild* = concept t
+      distinctBase(t)
+
+  proc `$`*[T: AdtChild](adtChild: T): string = ""
+
+  check 10 is int