summary refs log tree commit diff stats
path: root/compiler/semmacrosanity.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/semmacrosanity.nim')
-rw-r--r--compiler/semmacrosanity.nim18
1 files changed, 10 insertions, 8 deletions
diff --git a/compiler/semmacrosanity.nim b/compiler/semmacrosanity.nim
index bb9814a16..150680af7 100644
--- a/compiler/semmacrosanity.nim
+++ b/compiler/semmacrosanity.nim
@@ -38,14 +38,16 @@ proc annotateType*(n: PNode, t: PType) =
   # Note: x can be unequal to t and we need to be careful to use 't'
   # to not to skip tyGenericInst
   case n.kind
+  of nkObjConstr:
+    n.typ = t
+    for i in 1 .. <n.len:
+      let field = x.n.ithField(i - 1)
+      if field.isNil: globalError n.info, "invalid field at index " & $i
+      else:
+        internalAssert(n.sons[i].kind == nkExprColonExpr)
+        annotateType(n.sons[i].sons[1], field.typ)
   of nkPar:
-    if x.kind == tyObject:
-      n.typ = t
-      for i in 0 .. <n.len:
-        let field = x.n.ithField(i)
-        if field.isNil: globalError n.info, "invalid field at index " & $i
-        else: annotateType(n.sons[i], field.typ)
-    elif x.kind == tyTuple:
+    if x.kind == tyTuple:
       n.typ = t
       for i in 0 .. <n.len:
         if i >= x.len: globalError n.info, "invalid field at index " & $i
@@ -53,7 +55,7 @@ proc annotateType*(n: PNode, t: PType) =
     elif x.kind == tyProc and x.callConv == ccClosure:
       n.typ = t
     else:
-      globalError(n.info, "() must have an object or tuple type")
+      globalError(n.info, "() must have a tuple type")
   of nkBracket:
     if x.kind in {tyArrayConstr, tyArray, tySequence, tyOpenArray}:
       n.typ = t