summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-01-07 20:30:51 +0100
committerAraq <rumpf_a@web.de>2012-01-07 20:30:51 +0100
commit7f3b3298b4dc2be10febebc383f42187f968135e (patch)
tree241350ba9c93d1c2a1974df60ce23279b634e511
parent7405278138f4e76d5e6278b3ed25f953ba9260e1 (diff)
downloadNim-7f3b3298b4dc2be10febebc383f42187f968135e.tar.gz
fixes #33
-rwxr-xr-xcompiler/msgs.nim5
-rwxr-xr-xcompiler/semtypes.nim14
-rwxr-xr-xtests/compile/tgenericrefs.nim36
3 files changed, 29 insertions, 26 deletions
diff --git a/compiler/msgs.nim b/compiler/msgs.nim
index da2e682e8..ac884538d 100755
--- a/compiler/msgs.nim
+++ b/compiler/msgs.nim
@@ -547,10 +547,11 @@ type
 proc handleError(msg: TMsgKind, eh: TErrorHandling) = 
   if msg == errInternal: 
     assert(false)             # we want a stack trace here
-  if (msg >= fatalMin) and (msg <= fatalMax): 
+  if msg >= fatalMin and msg <= fatalMax: 
     if gVerbosity >= 3: assert(false)
     quit(1)
-  if (msg >= errMin) and (msg <= errMax): 
+  if msg >= errMin and msg <= errMax: 
+    if gVerbosity >= 3: assert(false)
     inc(gErrorCounter)
     options.gExitcode = 1'i8
     if gErrorCounter >= gErrorMax or eh == doAbort: 
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index 3d572f517..ff05586fa 100755
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -625,14 +625,18 @@ proc semGenericParamInInvokation(c: PContext, n: PNode): PType =
   result = semTypeNode(c, n, nil)
 
 proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType = 
-  if s.typ == nil or s.typ.kind != tyGenericBody: 
-    GlobalError(n.info, errCannotInstantiateX, s.name.s)
   result = newOrPrevType(tyGenericInvokation, prev, c)
-  if s.typ.containerID == 0: InternalError(n.info, "semtypes.semGeneric")
-  if sonsLen(n) != sonsLen(s.typ): 
+  var isConcrete = true
+  if s.typ == nil:
+    GlobalError(n.info, errCannotInstantiateX, s.name.s)
+  elif s.typ.kind != tyGenericBody:
+    isConcrete = false
+  elif s.typ.containerID == 0: 
+    InternalError(n.info, "semtypes.semGeneric")
+  elif sonsLen(n) != sonsLen(s.typ): 
     GlobalError(n.info, errWrongNumberOfArguments)
   addSon(result, s.typ)
-  var isConcrete = true # iterate over arguments:
+  # iterate over arguments:
   for i in countup(1, sonsLen(n)-1):
     var elem = semGenericParamInInvokation(c, n.sons[i])
     if containsGenericType(elem): isConcrete = false
diff --git a/tests/compile/tgenericrefs.nim b/tests/compile/tgenericrefs.nim
index 3b7940098..ef931dfa7 100755
--- a/tests/compile/tgenericrefs.nim
+++ b/tests/compile/tgenericrefs.nim
@@ -1,28 +1,26 @@
-discard """
-  disabled: true
-"""
-
-# Compiles:
-
 type 
-  TA[T] = object
   PA[T] = ref TA[T]
+  TA[T] = object
+    field: T
 var a: PA[string]
+new(a)
+a.field = "some string"
 
-# Compiles unless you use var a: PA[string]
-type 
-  PA = ref TA
-  TA[T] = object
+when false:
+  # Compiles unless you use var a: PA[string]
+  type 
+    PA = ref TA
+    TA[T] = object
 
 
-# Cannot instantiate:
-type 
-  TA[T] = object
-    a: PA[T]
-  PA[T] = ref TA[T]
+  # Cannot instantiate:
+  type 
+    TA[T] = object
+      a: PA[T]
+    PA[T] = ref TA[T]
 
-type 
-  PA[T] = ref TA[T]
-  TA[T] = object
+  type 
+    PA[T] = ref TA[T]
+    TA[T] = object