From fc740c54ec7af592ff3486c8cc296bb4f65eb340 Mon Sep 17 00:00:00 2001 From: jcosborn Date: Wed, 7 Nov 2018 01:40:00 -0600 Subject: [PATCH] fixes #9600 (#9601) --- compiler/vmdeps.nim | 5 ++++- tests/macros/tgettypeinst.nim | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim index 8aac5fb87496..f160a30967c3 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 6a99dc8b7bc4..c2cde9a43a76 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)