mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
committed by
Andreas Rumpf
parent
0149e418be
commit
367d232351
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
19
tests/statictypes/texplicitprocparams.nim
Normal file
19
tests/statictypes/texplicitprocparams.nim
Normal file
@@ -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]()
|
||||
|
||||
Reference in New Issue
Block a user