This commit is contained in:
Araq
2016-11-30 22:25:56 +01:00
parent 7b44896e03
commit 8494338bcb
4 changed files with 20 additions and 7 deletions

View File

@@ -1129,11 +1129,7 @@ proc genNewSeqOfCap(p: BProc; e: PNode; d: var TLoc) =
proc genConstExpr(p: BProc, n: PNode): Rope
proc handleConstExpr(p: BProc, n: PNode, d: var TLoc): bool =
proc forbiddenType(t: PType): bool {.inline.} =
result = t.kind == tyObject and not isObjLackingTypeField(t)
#echo "forbidden type ", result
if d.k == locNone and n.len > ord(n.kind == nkObjConstr) and n.isDeepConstExpr and
not forbiddenType(n.typ):
if d.k == locNone and n.len > ord(n.kind == nkObjConstr) and n.isDeepConstExpr:
var t = getUniqueType(n.typ)
discard getTypeDesc(p.module, t) # so that any fields are initialized
let id = nodeTableTestOrSet(p.module.dataCache, n, p.module.labels)
@@ -2156,6 +2152,9 @@ proc genNamedConstExpr(p: BProc, n: PNode): Rope =
proc genConstSimpleList(p: BProc, n: PNode): Rope =
var length = sonsLen(n)
result = rope("{")
if n.kind == nkObjConstr and not isObjLackingTypeField(n.typ):
addf(result, "{$1}", [genTypeInfo(p.module, n.typ)])
if n.len > 1: add(result, ",")
for i in countup(ord(n.kind == nkObjConstr), length - 2):
addf(result, "$1,$n", [genNamedConstExpr(p, n.sons[i])])
if length > ord(n.kind == nkObjConstr):

View File

@@ -27,8 +27,8 @@ const
cfsFieldInfo: "NIM_merge_FIELD_INFO",
cfsTypeInfo: "NIM_merge_TYPE_INFO",
cfsProcHeaders: "NIM_merge_PROC_HEADERS",
cfsData: "NIM_merge_DATA",
cfsVars: "NIM_merge_VARS",
cfsData: "NIM_merge_DATA",
cfsProcs: "NIM_merge_PROCS",
cfsInitProc: "NIM_merge_INIT_PROC",
cfsTypeInit1: "NIM_merge_TYPE_INIT1",

View File

@@ -27,8 +27,8 @@ type
cfsFieldInfo, # section for field information
cfsTypeInfo, # section for type information
cfsProcHeaders, # section for C procs prototypes
cfsData, # section for C constant data
cfsVars, # section for C variable declarations
cfsData, # section for C constant data
cfsProcs, # section for C procs that are not inline
cfsInitProc, # section for the C init proc
cfsTypeInit1, # section 1 for declarations of type information

View File

@@ -0,0 +1,14 @@
discard """
output: "@[(username: user, role: admin, description: desc, email_addr: email), (username: user, role: admin, description: desc, email_addr: email)]"
"""
type
User = object of RootObj
username, role, description, email_addr: string
# bug 5055
let us4 = @[
User(username:"user", role:"admin", description:"desc", email_addr:"email"),
User(username:"user", role:"admin", description:"desc", email_addr:"email"),
]
echo us4