diff options
author | Jasper Jenkins <jasper.vs.jenkins@gmail.com> | 2019-05-04 14:28:09 -0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-05-04 23:28:09 +0200 |
commit | 6e4ea40475095a74c40f94b0d01e4d878661720f (patch) | |
tree | 508894c455e66b67cc60151a34898381ed0362b5 | |
parent | ce152ed91f85c45909e0f76854fcc28d3c6a550d (diff) | |
download | Nim-6e4ea40475095a74c40f94b0d01e4d878661720f.tar.gz |
empty container param error msg (#11158)
-rw-r--r-- | compiler/semtypes.nim | 3 | ||||
-rw-r--r-- | tests/errmsgs/temptysetparam.nim | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index bd64af729..99fd62550 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -1133,6 +1133,9 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode, if typ == nil: typ = def.typ + if isEmptyContainer(typ): + localError(c.config, a.info, "cannot infer the type of parameter '" & a[0].ident.s & "'") + if typ.kind == tyTypeDesc: # consider a proc such as: # proc takesType(T = int) diff --git a/tests/errmsgs/temptysetparam.nim b/tests/errmsgs/temptysetparam.nim new file mode 100644 index 000000000..20763feda --- /dev/null +++ b/tests/errmsgs/temptysetparam.nim @@ -0,0 +1,5 @@ +discard """ + errormsg: "cannot infer the type of parameter 'x'" + line: 5 +""" +proc a(x = {}) = discard |