further tests for var T result type; ttables test now fails :-(

This commit is contained in:
Araq 2011-08-10 01:16:32 +02:00
commit d5dd4669df
4 changed files with 167 additions and 161 deletions

View file

@ -178,12 +178,11 @@ proc SemYieldVarResult(c: PContext, n: PNode, restype: PType) =
if e.kind == tyVar: if e.kind == tyVar:
if n.sons[0].kind == nkPar: if n.sons[0].kind == nkPar:
n.sons[0].sons[i] = takeImplicitAddr(c, n.sons[0].sons[i]) 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: n.sons[0].sons[1].kind == nkPar:
var a = n.sons[0].sons[1] var a = n.sons[0].sons[1]
a.sons[i] = takeImplicitAddr(c, a.sons[i]) a.sons[i] = takeImplicitAddr(c, a.sons[i])
else: else:
debug n.sons[0]
localError(n.sons[0].info, errXExpected, "tuple constructor") localError(n.sons[0].info, errXExpected, "tuple constructor")
else: nil else: nil

View file

@ -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: For iterators, a component of a tuple return type can have a ``var`` type too:
.. code-block:: nimrod .. 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: for i in 0..a.high:
yield (i, a[i]) 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 Overloading of the subscript operator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -2331,6 +2334,7 @@ Example:
add(root, newNode("hallo")) # instantiates generic procs ``newNode`` and add(root, newNode("hallo")) # instantiates generic procs ``newNode`` and
add(root, newNode("world")) # ``add`` add(root, newNode("world")) # ``add``
for str in inorder(root): for str in inorder(root):
writeln(stdout, str) writeln(stdout, str)
`Generics`:idx: are Nimrod's means to parametrize procs, iterators or types with `Generics`:idx: are Nimrod's means to parametrize procs, iterators or types with

View file

@ -60,6 +60,9 @@ block orderedTableTest1:
assert val == data[i][1] assert val == data[i][1]
inc(i) inc(i)
for key, val in mpairs(t): val = 99
for val in mvalues(t): assert val == 99
block countTableTest1: block countTableTest1:
var s = data.toTable var s = data.toTable
var t = initCountTable[string]() var t = initCountTable[string]()

View file

@ -1,7 +1,7 @@
Version 0.8.14 Version 0.8.14
============== ==============
- test ``m*`` for generics; document 'm' convention - test ``m*`` for generics
- optional indentation for 'case' statement - optional indentation for 'case' statement
- make threadvar efficient again on linux after testing - make threadvar efficient again on linux after testing
- test the sort implementation again - test the sort implementation again