summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-12-15 09:09:46 +0100
committerAndreas Rumpf <rumpf_a@web.de>2018-12-15 09:09:46 +0100
commit446f911a173a595648fa444c83d931193198eeb6 (patch)
tree8daf144e82a711c7768a748665c3feaba619de9a /compiler/semstmts.nim
parentf76bd06643d0b8ee4de18808eb73d78e9aa91270 (diff)
downloadNim-446f911a173a595648fa444c83d931193198eeb6.tar.gz
better error message for 'proc' that is not intended to be used as a typeclass
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 5be57f614..2d98d84e1 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -1090,9 +1090,13 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) =
 
 
 proc checkForMetaFields(c: PContext; n: PNode) =
-  template checkMeta(t) =
+  proc checkMeta(c: PContext; n: PNode; t: PType) =
     if t != nil and t.isMetaType and tfGenericTypeParam notin t.flags:
-      localError(c.config, n.info, errTIsNotAConcreteType % t.typeToString)
+      if t.kind == tyBuiltInTypeClass and t.len == 1 and t.sons[0].kind == tyProc:
+        localError(c.config, n.info, ("'$1' is not a concrete type; " &
+          "for a callback without parameters use 'proc()'") % t.typeToString)
+      else:
+        localError(c.config, n.info, errTIsNotAConcreteType % t.typeToString)
 
   if n.isNil: return
   case n.kind
@@ -1107,9 +1111,9 @@ proc checkForMetaFields(c: PContext; n: PNode) =
        tyProc, tyGenericInvocation, tyGenericInst, tyAlias, tySink:
       let start = ord(t.kind in {tyGenericInvocation, tyGenericInst})
       for i in start ..< t.len:
-        checkMeta(t.sons[i])
+        checkMeta(c, n, t.sons[i])
     else:
-      checkMeta(t)
+      checkMeta(c, n, t)
   else:
     internalAssert c.config, false