Skip to content

Commit

Permalink
remove prev == nil requirement for typedesc params as type nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Sep 30, 2024
1 parent b0e6d28 commit 69bc565
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/semtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2167,7 +2167,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
if s.kind != skError: localError(c.config, n.info, errTypeExpected)
result = newOrPrevType(tyError, prev, c)
elif s.kind == skParam and s.typ.kind == tyTypeDesc:
internalAssert c.config, s.typ.base.kind != tyNone and prev == nil
internalAssert c.config, s.typ.base.kind != tyNone
result = s.typ.base
elif prev == nil:
result = s.typ
Expand All @@ -2191,7 +2191,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
if s.kind == skType:
s.typ
else:
internalAssert c.config, s.typ.base.kind != tyNone and prev == nil
internalAssert c.config, s.typ.base.kind != tyNone
s.typ.base
let alias = maybeAliasType(c, t, prev)
if alias != nil:
Expand Down
9 changes: 9 additions & 0 deletions tests/metatype/tmetatype_issues.nim
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,12 @@ block t3338:
var t2 = Bar[int32]()
t2.add()
doAssert t2.x == 5

block: # issue #24203
proc b(G: typedesc) =
type U = G
template s(h: untyped) = h
s(b(typeof (0, 0)))
b(seq[int])
b((int, int))
b(typeof (0, 0))

0 comments on commit 69bc565

Please sign in to comment.