Skip to content

Commit

Permalink
fix #1017; fix #3309
Browse files Browse the repository at this point in the history
  • Loading branch information
zah authored and Araq committed Jun 20, 2017
1 parent 0149e41 commit 367d232
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/semcall.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions compiler/sigmatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 19 additions & 0 deletions tests/statictypes/texplicitprocparams.nim
Original file line number Diff line number Diff line change
@@ -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]()

0 comments on commit 367d232

Please sign in to comment.