further tests for var T result type; ttables test now fails :-(
This commit is contained in:
parent
72e7a98543
commit
d5dd4669df
4 changed files with 167 additions and 161 deletions
|
|
@ -178,12 +178,11 @@ proc SemYieldVarResult(c: PContext, n: PNode, restype: PType) =
|
|||
if e.kind == tyVar:
|
||||
if n.sons[0].kind == nkPar:
|
||||
n.sons[0].sons[i] = takeImplicitAddr(c, n.sons[0].sons[i])
|
||||
elif n.sons[0].kind == nkHiddenSubConv and
|
||||
elif n.sons[0].kind in {nkHiddenStdConv, nkHiddenSubConv} and
|
||||
n.sons[0].sons[1].kind == nkPar:
|
||||
var a = n.sons[0].sons[1]
|
||||
a.sons[i] = takeImplicitAddr(c, a.sons[i])
|
||||
else:
|
||||
debug n.sons[0]
|
||||
localError(n.sons[0].info, errXExpected, "tuple constructor")
|
||||
else: nil
|
||||
|
||||
|
|
|
|||
|
|
@ -2095,10 +2095,13 @@ used to access a location beyond its lifetime:
|
|||
For iterators, a component of a tuple return type can have a ``var`` type too:
|
||||
|
||||
.. code-block:: nimrod
|
||||
iterator modPairs(a: var seq[string]): tuple[key: int, val: var string] =
|
||||
iterator mpairs(a: var seq[string]): tuple[key: int, val: var string] =
|
||||
for i in 0..a.high:
|
||||
yield (i, a[i])
|
||||
|
||||
In the standard library every name of a routine that returns a ``var`` type
|
||||
starts with the prefix ``m`` per convention.
|
||||
|
||||
|
||||
Overloading of the subscript operator
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
@ -2331,6 +2334,7 @@ Example:
|
|||
add(root, newNode("hallo")) # instantiates generic procs ``newNode`` and
|
||||
add(root, newNode("world")) # ``add``
|
||||
for str in inorder(root):
|
||||
|
||||
writeln(stdout, str)
|
||||
|
||||
`Generics`:idx: are Nimrod's means to parametrize procs, iterators or types with
|
||||
|
|
|
|||
|
|
@ -60,6 +60,9 @@ block orderedTableTest1:
|
|||
assert val == data[i][1]
|
||||
inc(i)
|
||||
|
||||
for key, val in mpairs(t): val = 99
|
||||
for val in mvalues(t): assert val == 99
|
||||
|
||||
block countTableTest1:
|
||||
var s = data.toTable
|
||||
var t = initCountTable[string]()
|
||||
|
|
|
|||
2
todo.txt
2
todo.txt
|
|
@ -1,7 +1,7 @@
|
|||
Version 0.8.14
|
||||
==============
|
||||
|
||||
- test ``m*`` for generics; document 'm' convention
|
||||
- test ``m*`` for generics
|
||||
- optional indentation for 'case' statement
|
||||
- make threadvar efficient again on linux after testing
|
||||
- test the sort implementation again
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue