diff options
author | Araq <rumpf_a@web.de> | 2015-06-06 13:25:20 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-06-06 13:25:20 +0200 |
commit | 54750f608df65b1f56035da424cc2c9098e70841 (patch) | |
tree | 883f5d4bc7b2d545f63cefc0074d7c924e95b29f | |
parent | d94fcb38f04c51ecc7929a7b9649ef21738592d7 (diff) | |
download | Nim-54750f608df65b1f56035da424cc2c9098e70841.tar.gz |
fixes #2774
-rw-r--r-- | compiler/ccgexprs.nim | 2 | ||||
-rw-r--r-- | tests/vm/tconstobj.nim | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 05a3602d1..64902c3fc 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2150,7 +2150,7 @@ proc genNamedConstExpr(p: BProc, n: PNode): Rope = proc genConstSimpleList(p: BProc, n: PNode): Rope = var length = sonsLen(n) result = rope("{") - for i in countup(0, length - 2): + for i in countup(ord(n.kind == nkObjConstr), length - 2): addf(result, "$1,$n", [genNamedConstExpr(p, n.sons[i])]) if length > 0: add(result, genNamedConstExpr(p, n.sons[length - 1])) addf(result, "}$n", []) diff --git a/tests/vm/tconstobj.nim b/tests/vm/tconstobj.nim new file mode 100644 index 000000000..414708945 --- /dev/null +++ b/tests/vm/tconstobj.nim @@ -0,0 +1,14 @@ +discard """ + output: '''(name: hello)''' +""" + +# bug #2774 + +type Foo = object + name: string + +const fooArray = [ + Foo(name: "hello") +] + +echo fooArray[0] |