summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2017-06-10 23:14:25 +0300
committerAndreas Rumpf <rumpf_a@web.de>2017-06-20 11:29:42 +0200
commit367d23235182ad9468d1e83e9380d2eea0c134b1 (patch)
treea28f9b1b6bf5a72518971d8d68e66900253aff05
parent0149e418bec1b4433ea3d2e03a30735c1b7b16a3 (diff)
downloadNim-367d23235182ad9468d1e83e9380d2eea0c134b1.tar.gz
fix #1017; fix #3309
-rw-r--r--compiler/semcall.nim3
-rw-r--r--compiler/sigmatch.nim6
-rw-r--r--tests/statictypes/texplicitprocparams.nim19
3 files changed, 27 insertions, 1 deletions
diff --git a/compiler/semcall.nim b/compiler/semcall.nim
index 881532d57..5984e25e0 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 4a6ff3fce..725f8e287 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 000000000..149330cb7
--- /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]()
+