summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-01-13 13:40:05 +0100
committerAraq <rumpf_a@web.de>2012-01-13 13:40:05 +0100
commite362cbbfd79f5b95ad0c7a218a3f7a35d91edbf7 (patch)
treeca39a785ce9d0d9c3c225326f81af36d8ebf7974
parent76886432dad6df8e1a381286a918381554bab08b (diff)
downloadNim-e362cbbfd79f5b95ad0c7a218a3f7a35d91edbf7.tar.gz
bugfix: tests/reject/tnoinst.nim is now rejected properly
-rwxr-xr-xcompiler/ast.nim6
-rwxr-xr-xcompiler/msgs.nim3
-rwxr-xr-xcompiler/semexprs.nim2
-rw-r--r--tests/reject/tnoinst.nim16
-rwxr-xr-xtodo.txt2
5 files changed, 27 insertions, 2 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 46dc5e0de..b936ec3b4 100755
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -1022,3 +1022,9 @@ proc getStrOrChar*(a: PNode): string =
     internalError(a.info, "getStrOrChar")
     result = ""
 
+proc isGenericRoutine*(s: PSym): bool = 
+  case s.kind
+  of skProc, skTemplate, skMacro, skIterator:
+    result = s.ast != nil and s.ast[genericParamsPos].kind != nkEmpty
+  else: nil
+
diff --git a/compiler/msgs.nim b/compiler/msgs.nim
index 3865a0c7a..6cb2fedcd 100755
--- a/compiler/msgs.nim
+++ b/compiler/msgs.nim
@@ -85,7 +85,7 @@ type
     errInvalidIndexValueForTuple, errCommandExpectsFilename, errXExpected, 
     errInvalidSectionStart, errGridTableNotImplemented, errGeneralParseError, 
     errNewSectionExpected, errWhitespaceExpected, errXisNoValidIndexFile, 
-    errCannotRenderX, errVarVarTypeNotAllowed, 
+    errCannotRenderX, errVarVarTypeNotAllowed, errInstantiateXExplicitely,
     
     errXExpectsTwoArguments, 
     errXExpectsObjectTypes, errXcanNeverBeOfThisSubtype, errTooManyIterations, 
@@ -306,6 +306,7 @@ const
     errXisNoValidIndexFile: "\'$1\' is no valid index file", 
     errCannotRenderX: "cannot render reStructuredText element \'$1\'", 
     errVarVarTypeNotAllowed: "type \'var var\' is not allowed",
+    errInstantiateXExplicitely: "instantiate '$1' explicitely",
     errXExpectsTwoArguments: "\'$1\' expects two arguments", 
     errXExpectsObjectTypes: "\'$1\' expects object types",
     errXcanNeverBeOfThisSubtype: "\'$1\' can never be of this subtype", 
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 8c6c86ef6..32244af85 100755
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -58,6 +58,8 @@ proc semSym(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
         smoduleId != c.module.id and smoduleId != c.friendModule.id: 
       LocalError(n.info, errXCannotBePassedToProcVar, s.name.s)
     result = symChoice(c, n, s)
+    if result.kind == nkSym and isGenericRoutine(result.sym):
+      LocalError(n.info, errInstantiateXExplicitely, s.name.s)
   of skConst:
     markUsed(n, s)
     case skipTypes(s.typ, abstractInst).kind
diff --git a/tests/reject/tnoinst.nim b/tests/reject/tnoinst.nim
new file mode 100644
index 000000000..23a4145e0
--- /dev/null
+++ b/tests/reject/tnoinst.nim
@@ -0,0 +1,16 @@
+discard """
+  line: 12
+  errormsg: "instantiate 'notConcrete' explicitely"
+"""
+
+proc wrap[T]() =
+  proc notConcrete[T](x, y: int): int =
+    var dummy: T
+    result = x - y
+
+  var x: proc (x, y: T): int
+  x = notConcrete
+  
+
+wrap[int]()
+
diff --git a/todo.txt b/todo.txt
index 29aff15b0..fc09e5400 100755
--- a/todo.txt
+++ b/todo.txt
@@ -44,7 +44,7 @@ Bugs
 - bug: stress testing basic method example (eval example) 
   without ``-d:release`` leaks memory; good way to figure out how a 
   fixed amount of stack can hold an arbitrary number of GC roots!
-- BUG: temp2.nim triggers weird compiler and except.nim bug
+- bug: temp2.nim triggers weird compiler and except.nim bug
 - bug: tsortdev does not run