summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2014-02-17 00:47:45 +0200
committerZahary Karadjov <zahary@gmail.com>2014-02-17 00:47:45 +0200
commitb80503814d3ad37023b27cc8b2d78aed0c10bfcb (patch)
treef07f3505b3fc99cf891e3a1fb8ab5a43d9d56838 /compiler/semstmts.nim
parent74f49014303a87a8cf649d6d0aec041d683509cd (diff)
downloadNim-b80503814d3ad37023b27cc8b2d78aed0c10bfcb.tar.gz
fix #188
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim24
1 files changed, 24 insertions, 0 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 0871b7fb7..e592b1e81 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -764,6 +764,28 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) =
       s.ast = a
       popOwner()
 
+proc checkForMetaFields(n: PNode) =
+  template checkMeta(t) =
+    if t.isMetaType and tfGenericTypeParam notin t.flags:
+      localError(n.info, errTIsNotAConcreteType, t.typeToString)
+  
+  case n.kind
+  of nkRecList, nkRecCase:
+    for s in n: checkForMetaFields(s)
+  of nkOfBranch, nkElse:
+    checkForMetaFields(n.lastSon)
+  of nkSym:
+    let t = n.sym.typ
+    case t.kind
+    of tySequence, tySet, tyArray, tyOpenArray, tyVar, tyPtr, tyRef,
+       tyProc, tyGenericInvokation, tyGenericInst:
+      for s in t.sons:
+        checkMeta(s)
+    else:
+      checkMeta(t)
+  else:
+    internalAssert false
+
 proc typeSectionFinalPass(c: PContext, n: PNode) = 
   for i in countup(0, sonsLen(n) - 1): 
     var a = n.sons[i]
@@ -780,6 +802,8 @@ 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}:
+        checkForMetaFields(s.typ.n)
     let aa = a.sons[2]
     if aa.kind in {nkRefTy, nkPtrTy} and aa.len == 1 and
        aa.sons[0].kind == nkObjectTy: