iterable[T] (#17196)
* fix failing test toSeq in manual which now works * changelog * reject proc fn(a: iterable) * add iterable to spec * remove MCS/UFCS limitation that now works
This commit is contained in:
parent
a5b30c94c2
commit
ceadf54d76
18 changed files with 254 additions and 40 deletions
|
|
@ -356,6 +356,15 @@ proc semArray(c: PContext, n: PNode, prev: PType): PType =
|
|||
localError(c.config, n.info, errArrayExpectsTwoTypeParams)
|
||||
result = newOrPrevType(tyError, prev, c)
|
||||
|
||||
proc semIterableType(c: PContext, n: PNode, prev: PType): PType =
|
||||
result = newOrPrevType(tyIterable, prev, c)
|
||||
if n.len == 2:
|
||||
let base = semTypeNode(c, n[1], nil)
|
||||
addSonSkipIntLit(result, base, c.idgen)
|
||||
else:
|
||||
localError(c.config, n.info, errXExpectsOneTypeParam % "iterable")
|
||||
result = newOrPrevType(tyError, prev, c)
|
||||
|
||||
proc semOrdinal(c: PContext, n: PNode, prev: PType): PType =
|
||||
result = newOrPrevType(tyOrdinal, prev, c)
|
||||
if n.len == 2:
|
||||
|
|
@ -1844,6 +1853,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
|||
of mRange: result = semRange(c, n, prev)
|
||||
of mSet: result = semSet(c, n, prev)
|
||||
of mOrdinal: result = semOrdinal(c, n, prev)
|
||||
of mIterableType: result = semIterableType(c, n, prev)
|
||||
of mSeq:
|
||||
result = semContainer(c, n, tySequence, "seq", prev)
|
||||
if optSeqDestructors in c.config.globalOptions:
|
||||
|
|
@ -2067,6 +2077,9 @@ proc processMagicType(c: PContext, m: PSym) =
|
|||
of mOrdinal:
|
||||
setMagicIntegral(c.config, m, tyOrdinal, szUncomputedSize)
|
||||
rawAddSon(m.typ, newTypeS(tyNone, c))
|
||||
of mIterableType:
|
||||
setMagicIntegral(c.config, m, tyIterable, 0)
|
||||
rawAddSon(m.typ, newTypeS(tyNone, c))
|
||||
of mPNimrodNode:
|
||||
incl m.typ.flags, tfTriggersCompileTime
|
||||
incl m.typ.flags, tfCheckedForDestructor
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue