From 7527da7043570aaea70b9db2e07c7de01622e3b1 Mon Sep 17 00:00:00 2001 From: Max Zerzouri Date: Sat, 7 Mar 2015 10:43:47 +1300 Subject: [PATCH] .n.isNil checks for tyTuple PTypes. --- compiler/evalffi.nim | 1 + compiler/sempass2.nim | 2 +- compiler/semstmts.nim | 2 +- compiler/semtypinst.nim | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/evalffi.nim b/compiler/evalffi.nim index b98679ac60..b1a23802d0 100644 --- a/compiler/evalffi.nim +++ b/compiler/evalffi.nim @@ -164,6 +164,7 @@ proc packObject(x: PNode, typ: PType, res: pointer) = let field = getField(typ.n, i) pack(it, field.typ, res +! field.offset) else: + # XXX: todo globalError(x.info, "cannot pack unnamed tuple") const maxPackDepth = 20 diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 60153e0521..14644a8d69 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -138,7 +138,7 @@ proc guardDotAccess(a: PEffects; n: PNode) = if g.kind == skUnknown: var field: PSym = nil var ty = n.sons[0].typ.skipTypes(abstractPtrs) - if ty.kind == tyTuple: + if ty.kind == tyTuple and not ty.n.isNil: field = lookupInRecord(ty.n, g.name) else: while ty != nil and ty.kind == tyObject: diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 3fbb6f8f3d..ccfd746074 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -692,7 +692,7 @@ proc typeSectionFinalPass(c: PContext, n: PNode) = assignType(s.typ, t) s.typ.id = t.id # same id checkConstructedType(s.info, s.typ) - if s.typ.kind in {tyObject, tyTuple}: + if s.typ.kind in {tyObject, tyTuple} and not s.typ.n.isNil: checkForMetaFields(s.typ.n) let aa = a.sons[2] if aa.kind in {nkRefTy, nkPtrTy} and aa.len == 1 and diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index 57aa6305e0..012782730a 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -341,6 +341,8 @@ proc skipIntLiteralParams*(t: PType) = proc propagateFieldFlags(t: PType, n: PNode) = # This is meant for objects and tuples # The type must be fully instantiated! + if n.isNil: + return internalAssert n.kind != nkRecWhen case n.kind of nkSym: