diff options
author | LemonBoy <LemonBoy@users.noreply.github.com> | 2018-07-30 10:51:14 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-07-30 10:51:14 +0200 |
commit | c3a9ac4d352a84fb47da0a4d5fc6f963b651bbec (patch) | |
tree | ffabccbe9fd3bf0c448661abc32c2b5c85b48580 /compiler/semcall.nim | |
parent | becb6743f8197f53897cef1b2fda97f1784f961c (diff) | |
download | Nim-c3a9ac4d352a84fb47da0a4d5fc6f963b651bbec.tar.gz |
Try conversion to static[T] in generic instantation (#8443)
Fixes #8439
Diffstat (limited to 'compiler/semcall.nim')
-rw-r--r-- | compiler/semcall.nim | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 67fe99232..aa5394a71 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -505,7 +505,15 @@ proc explicitGenericSym(c: PContext, n: PNode, s: PSym): PNode = for i in 1..sonsLen(n)-1: let formal = s.ast.sons[genericParamsPos].sons[i-1].typ - let arg = n[i].typ + var arg = n[i].typ + # try transforming the argument into a static one before feeding it into + # typeRel + if formal.kind == tyStatic and arg.kind != tyStatic: + let evaluated = c.semTryConstExpr(c, n[i]) + if evaluated != nil: + arg = newTypeS(tyStatic, c) + arg.sons = @[evaluated.typ] + arg.n = evaluated let tm = typeRel(m, formal, arg) if tm in {isNone, isConvertible}: return nil var newInst = generateInstance(c, s, m.bindings, n.info) |