From 367d23235182ad9468d1e83e9380d2eea0c134b1 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sat, 10 Jun 2017 23:14:25 +0300 Subject: [PATCH] fix #1017; fix #3309 --- compiler/semcall.nim | 3 ++- compiler/sigmatch.nim | 6 ++++++ tests/statictypes/texplicitprocparams.nim | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/statictypes/texplicitprocparams.nim diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 881532d57571..5984e25e080a 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -446,7 +446,8 @@ proc explicitGenericSym(c: PContext, n: PNode, s: PSym): PNode = proc explicitGenericInstantiation(c: PContext, n: PNode, s: PSym): PNode = assert n.kind == nkBracketExpr for i in 1..sonsLen(n)-1: - n.sons[i].typ = semTypeNode(c, n.sons[i], nil) + let e = semExpr(c, n.sons[i]) + n.sons[i].typ = e.typ.skipTypes({tyTypeDesc}) var s = s var a = n.sons[0] if a.kind == nkSym: diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 4a6ff3fced41..725f8e287ff0 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1578,6 +1578,12 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType, if not exprStructuralEquivalent(f.n, aOrig.n): result = isNone if result != isNone: put(c, f, aOrig) + elif aOrig.n != nil: + result = typeRel(c, f.lastSon, aOrig.n.typ) + if result != isNone: + var boundType = newTypeWithSons(c.c, tyStatic, @[aOrig.n.typ]) + boundType.n = aOrig.n + put(c, f, boundType) else: result = isNone elif prev.kind == tyStatic: diff --git a/tests/statictypes/texplicitprocparams.nim b/tests/statictypes/texplicitprocparams.nim new file mode 100644 index 000000000000..149330cb723e --- /dev/null +++ b/tests/statictypes/texplicitprocparams.nim @@ -0,0 +1,19 @@ +discard """ +output: ''' +(x: 100) +5 +''' +""" + +type + OdArray*[As: static[int], T] = object + x: int + +proc initOdArray*[As: static[int], T](len: int): OdArray[As, T] = + result.l = len + +echo initOdArray[10, int](100) + +proc doStatic[N: static[int]](): int = N +echo doStatic[5]() +