diff options
-rwxr-xr-x | compiler/semexprs.nim | 19 | ||||
-rwxr-xr-x | doc/manual.txt | 4 | ||||
-rwxr-xr-x | web/news.txt | 31 |
3 files changed, 47 insertions, 7 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 4608d38ef..17e6e8048 100755 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1364,19 +1364,28 @@ proc semSetConstr(c: PContext, n: PNode): PNode = m = fitNode(c, typ, n.sons[i]) addSon(result, m) -proc semTableConstr(c: PContext, n: PNode): PNode = - # we simply transform ``{key: value, key2: value}`` to - # ``[(key, value), (key2, value2)]`` +proc semTableConstr(c: PContext, n: PNode): PNode = + # we simply transform ``{key: value, key2, key3: value}`` to + # ``[(key, value), (key2, value2), (key3, value2)]`` result = newNodeI(nkBracket, n.info) + var lastKey = 0 for i in 0..n.len-1: var x = n.sons[i] if x.kind == nkExprColonExpr and sonsLen(x) == 2: + for j in countup(lastKey, i-1): + var pair = newNodeI(nkPar, x.info) + pair.add(n.sons[j]) + pair.add(x[1]) + result.add(pair) + var pair = newNodeI(nkPar, x.info) pair.add(x[0]) pair.add(x[1]) result.add(pair) - else: - illFormedAst(x) + + lastKey = i+1 + + if lastKey != n.len: illFormedAst(n) result = semExpr(c, result) type diff --git a/doc/manual.txt b/doc/manual.txt index 4d9375f30..b5f5d9d63 100755 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -2244,10 +2244,10 @@ Table constructor A `table constructor`:idx: is syntactic sugar for an array constructor: .. code-block:: nimrod - {"key1": "value1", "key2": "value2"} + {"key1": "value1", "key2", "key3": "value2"} # is the same as: - [("key1", "value1"), ("key2", "value2")] + [("key1", "value1"), ("key2", "value2"), ("key3", "value")] The empty table can be written ``{:}`` (in contrast to the empty set diff --git a/web/news.txt b/web/news.txt index fb133b6fe..d063c3974 100755 --- a/web/news.txt +++ b/web/news.txt @@ -2,6 +2,37 @@ News ==== +2012-XX-XX Version 0.9.XX released +================================== + +Version 0.8.XX has been released! Get it `here <download.html>`_. + +Bugfixes +-------- + + + +Library Additions +----------------- + + + +Changes affecting backwards compatibility +----------------------------------------- + + + +Compiler Additions +------------------ + + + +Language Additions +------------------ + +- table constructors now mimic more closely the syntax of case... of... + + 2012-09-23 Version 0.9.0 released ================================= |