fixes #1656
This commit is contained in:
parent
516a4d933f
commit
61c5c92f09
4 changed files with 9 additions and 4 deletions
0
build.sh
Executable file → Normal file
0
build.sh
Executable file → Normal file
|
|
@ -854,7 +854,9 @@ proc semParamType(c: PContext, n: PNode, constraint: var PNode): PType =
|
||||||
result = semTypeNode(c, n, nil)
|
result = semTypeNode(c, n, nil)
|
||||||
|
|
||||||
proc semProcTypeNode(c: PContext, n, genericParams: PNode,
|
proc semProcTypeNode(c: PContext, n, genericParams: PNode,
|
||||||
prev: PType, kind: TSymKind): PType =
|
prev: PType, kind: TSymKind; isType=false): PType =
|
||||||
|
# for historical reasons (code grows) this is invoked for parameter
|
||||||
|
# lists too and then 'isType' is false.
|
||||||
var
|
var
|
||||||
res: PNode
|
res: PNode
|
||||||
cl: IntSet
|
cl: IntSet
|
||||||
|
|
@ -903,7 +905,8 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
|
||||||
# proc sort[T](cmp: proc(a, b: T): int = cmp)
|
# proc sort[T](cmp: proc(a, b: T): int = cmp)
|
||||||
if not containsGenericType(typ):
|
if not containsGenericType(typ):
|
||||||
def = fitNode(c, typ, def)
|
def = fitNode(c, typ, def)
|
||||||
if not (hasType or hasDefault):
|
if not hasType and not hasDefault:
|
||||||
|
if isType: localError(a.info, "':' expected")
|
||||||
let tdef = if kind in {skTemplate, skMacro}: tyExpr else: tyAnything
|
let tdef = if kind in {skTemplate, skMacro}: tyExpr else: tyAnything
|
||||||
typ = newTypeS(tdef, c)
|
typ = newTypeS(tdef, c)
|
||||||
|
|
||||||
|
|
@ -929,6 +932,7 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
|
||||||
if n.sons[0].kind != nkEmpty:
|
if n.sons[0].kind != nkEmpty:
|
||||||
r = semTypeNode(c, n.sons[0], nil)
|
r = semTypeNode(c, n.sons[0], nil)
|
||||||
elif kind == skIterator:
|
elif kind == skIterator:
|
||||||
|
# XXX This is special magic we should likely get rid of
|
||||||
r = newTypeS(tyAnything, c)
|
r = newTypeS(tyAnything, c)
|
||||||
|
|
||||||
if r != nil:
|
if r != nil:
|
||||||
|
|
@ -1069,7 +1073,7 @@ proc semProcTypeWithScope(c: PContext, n: PNode,
|
||||||
prev: PType, kind: TSymKind): PType =
|
prev: PType, kind: TSymKind): PType =
|
||||||
checkSonsLen(n, 2)
|
checkSonsLen(n, 2)
|
||||||
openScope(c)
|
openScope(c)
|
||||||
result = semProcTypeNode(c, n.sons[0], nil, prev, kind)
|
result = semProcTypeNode(c, n.sons[0], nil, prev, kind, isType=true)
|
||||||
# dummy symbol for `pragma`:
|
# dummy symbol for `pragma`:
|
||||||
var s = newSymS(kind, newIdentNode(getIdent("dummy"), n.info), c)
|
var s = newSymS(kind, newIdentNode(getIdent("dummy"), n.info), c)
|
||||||
s.typ = result
|
s.typ = result
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ iterator foo[T](x: iterator: T{.inline.}): T =
|
||||||
|
|
||||||
var s = @[1, 2, 3]
|
var s = @[1, 2, 3]
|
||||||
|
|
||||||
# pass an interator several levels deep:
|
# pass an iterator several levels deep:
|
||||||
for x in s.items.foo:
|
for x in s.items.foo:
|
||||||
echo x
|
echo x
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
msg: "static 10\ndynamic\nstatic 20\n"
|
msg: "static 10\ndynamic\nstatic 20\n"
|
||||||
output: "s\nd\nd\ns"
|
output: "s\nd\nd\ns"
|
||||||
|
disabled: "true"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc foo(x: semistatic[int]) =
|
proc foo(x: semistatic[int]) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue