fixes #5999
This commit is contained in:
parent
da2f689e09
commit
1bb086e7a8
1 changed files with 8 additions and 2 deletions
|
|
@ -39,13 +39,19 @@ proc mergeInitStatus(existing: var InitStatus, newStatus: InitStatus) =
|
||||||
of initUnknown:
|
of initUnknown:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
|
proc invalidObjConstr(n: PNode) =
|
||||||
|
if n.kind == nkInfix and n[0].kind == nkIdent and n[0].ident.s[0] == ':':
|
||||||
|
localError(n.info, "incorrect object construction syntax; use a space after the colon")
|
||||||
|
else:
|
||||||
|
localError(n.info, "incorrect object construction syntax")
|
||||||
|
|
||||||
proc locateFieldInInitExpr(field: PSym, initExpr: PNode): PNode =
|
proc locateFieldInInitExpr(field: PSym, initExpr: PNode): PNode =
|
||||||
# Returns the assignment nkExprColonExpr node or nil
|
# Returns the assignment nkExprColonExpr node or nil
|
||||||
let fieldId = field.name.id
|
let fieldId = field.name.id
|
||||||
for i in 1 ..< initExpr.len:
|
for i in 1 ..< initExpr.len:
|
||||||
let assignment = initExpr[i]
|
let assignment = initExpr[i]
|
||||||
if assignment.kind != nkExprColonExpr:
|
if assignment.kind != nkExprColonExpr:
|
||||||
localError(initExpr.info, "incorrect object construction syntax")
|
invalidObjConstr(assignment)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if fieldId == considerQuotedIdent(assignment[0]).id:
|
if fieldId == considerQuotedIdent(assignment[0]).id:
|
||||||
|
|
@ -284,7 +290,7 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
let field = result[i]
|
let field = result[i]
|
||||||
if nfSem notin field.flags:
|
if nfSem notin field.flags:
|
||||||
if field.kind != nkExprColonExpr:
|
if field.kind != nkExprColonExpr:
|
||||||
localError(n.info, "incorrect object construction syntax")
|
invalidObjConstr(field)
|
||||||
continue
|
continue
|
||||||
let id = considerQuotedIdent(field[0])
|
let id = considerQuotedIdent(field[0])
|
||||||
# This node was not processed. There are two possible reasons:
|
# This node was not processed. There are two possible reasons:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue