diff options
author | Araq <rumpf_a@web.de> | 2017-12-14 20:55:02 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-12-14 20:55:02 +0100 |
commit | 1bb086e7a8e8cf836b99e8332203641c9e626ab6 (patch) | |
tree | 229e894b2d09b3ff97402e76c76a37625180a9ff | |
parent | da2f689e09d9eb6a3a3af6c5f7f8f06fc17c48ea (diff) | |
download | Nim-1bb086e7a8e8cf836b99e8332203641c9e626ab6.tar.gz |
fixes #5999
-rw-r--r-- | compiler/semobjconstr.nim | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/semobjconstr.nim b/compiler/semobjconstr.nim index 56d160aa4..a0bf084fa 100644 --- a/compiler/semobjconstr.nim +++ b/compiler/semobjconstr.nim @@ -39,13 +39,19 @@ proc mergeInitStatus(existing: var InitStatus, newStatus: InitStatus) = of initUnknown: 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 = # Returns the assignment nkExprColonExpr node or nil let fieldId = field.name.id for i in 1 ..< initExpr.len: let assignment = initExpr[i] if assignment.kind != nkExprColonExpr: - localError(initExpr.info, "incorrect object construction syntax") + invalidObjConstr(assignment) continue if fieldId == considerQuotedIdent(assignment[0]).id: @@ -284,7 +290,7 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode = let field = result[i] if nfSem notin field.flags: if field.kind != nkExprColonExpr: - localError(n.info, "incorrect object construction syntax") + invalidObjConstr(field) continue let id = considerQuotedIdent(field[0]) # This node was not processed. There are two possible reasons: |