summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/vmdeps.nim5
-rw-r--r--tests/macros/tgettypeinst.nim11
2 files changed, 15 insertions, 1 deletions
diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim
index 8aac5fb87..f160a3096 100644
--- a/compiler/vmdeps.nim
+++ b/compiler/vmdeps.nim
@@ -157,7 +157,10 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo;
   of tyObject:
     if inst:
       result = newNodeX(nkObjectTy)
-      result.add t.sym.ast[2][0].copyTree  # copy object pragmas
+      if t.sym.ast != nil:
+        result.add t.sym.ast[2][0].copyTree  # copy object pragmas
+      else:
+        result.add newNodeI(nkEmpty, info)
       if t.sons[0] == nil:
         result.add newNodeI(nkEmpty, info)
       else:  # handle parent object
diff --git a/tests/macros/tgettypeinst.nim b/tests/macros/tgettypeinst.nim
index 6a99dc8b7..c2cde9a43 100644
--- a/tests/macros/tgettypeinst.nim
+++ b/tests/macros/tgettypeinst.nim
@@ -201,3 +201,14 @@ test(MyObj):
     _ = object {.packed,myAttr,serializationKey: "one".}
       myField: int
       myField2: float
+
+block t9600:
+  type
+    Apple = ref object of RootObj
+
+  macro mixer(x: typed): untyped =
+    let w = getType(x)
+    let v = getTypeImpl(w[1])
+
+  var z: Apple
+  mixer(z)