mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-02 18:07:59 +00:00
fixes #2774
This commit is contained in:
@@ -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", [])
|
||||
|
||||
14
tests/vm/tconstobj.nim
Normal file
14
tests/vm/tconstobj.nim
Normal file
@@ -0,0 +1,14 @@
|
||||
discard """
|
||||
output: '''(name: hello)'''
|
||||
"""
|
||||
|
||||
# bug #2774
|
||||
|
||||
type Foo = object
|
||||
name: string
|
||||
|
||||
const fooArray = [
|
||||
Foo(name: "hello")
|
||||
]
|
||||
|
||||
echo fooArray[0]
|
||||
Reference in New Issue
Block a user