From dc1bf1e482e37175268fea787423e6fe177792f3 Mon Sep 17 00:00:00 2001 From: "Andrey R (cooldome)" Date: Sun, 15 Nov 2020 12:21:55 +0000 Subject: [PATCH] fix #15959 --- compiler/semexprs.nim | 3 +++ compiler/semtypinst.nim | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index b2f0207e7caa..a60c1669e1e1 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -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 diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index 931581d12a09..540b9c45e043 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -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