Skip to content

Commit

Permalink
Skip tyAlias inside semTypeTraits in case a concept accidently emits …
Browse files Browse the repository at this point in the history
…one (#23640)
  • Loading branch information
beef331 committed May 23, 2024
1 parent 6cd03ba commit d837d32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/semmagic.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions tests/metatype/ttypetraits.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d837d32

Please sign in to comment.