Skip to content

Commit

Permalink
fix #15959
Browse files Browse the repository at this point in the history
  • Loading branch information
cooldome committed Nov 15, 2020
1 parent c1664f9 commit dc1bf1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,9 @@ proc semSubscript(c: PContext, n: PNode, flags: TExprFlags): PNode =
result = n
else:
result = nil
of tyGenericParam:
result = n
result.typ = makeTypeFromExpr(c, n.copyTree)
else:
let s = if n[0].kind == nkSym: n[0].sym
elif n[0].kind in nkSymChoices: n[0][0].sym
Expand Down
7 changes: 5 additions & 2 deletions compiler/semtypinst.nim
Original file line number Diff line number Diff line change
Expand Up @@ -538,14 +538,17 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
assert t.n.typ != t
var n = prepareNode(cl, t.n)
if n.kind != nkEmpty:
n = cl.c.semConstExpr(cl.c, n)
if n.typ.kind == tyTypeDesc:
n = cl.c.semExpr(cl.c, n)
case n.typ.kind
of ConcreteTypes: result = n.typ
of tyTypeDesc:
# XXX: sometimes, chained typedescs enter here.
# It may be worth investigating why this is happening,
# because it may cause other bugs elsewhere.
result = n.typ.skipTypes({tyTypeDesc})
# result = n.typ.base
else:
n = cl.c.semConstExpr(cl.c, n)
if n.typ.kind != tyStatic:
# XXX: In the future, semConstExpr should
# return tyStatic values to let anyone make
Expand Down

0 comments on commit dc1bf1e

Please sign in to comment.