better error messages

This commit is contained in:
Araq 2018-03-18 12:04:22 +01:00
commit b0994c7f92
3 changed files with 17 additions and 3 deletions

View file

@ -192,6 +192,10 @@ proc semConv(c: PContext, n: PNode): PNode =
result.addSon copyTree(n.sons[0])
# special case to make MyObject(x = 3) produce a nicer error message:
if n[1].kind == nkExprEqExpr and
targetType.skipTypes(abstractPtrs).kind == tyObject:
localError(n.info, "object contruction uses ':', not '='")
var op = semExprWithType(c, n.sons[1])
if targetType.isMetaType:
let final = inferWithMetatype(c, targetType, op, true)