summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-03-05 06:25:33 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-03-05 06:25:33 +0100
commite0437dfec48fb9db40b8db20323fcc37f687f7db (patch)
tree76a922b87a768ad415375d0d17fb82c16ed0e4ec
parent9a9c002abe8037944f5f736bb310862a91b59861 (diff)
downloadNim-e0437dfec48fb9db40b8db20323fcc37f687f7db.tar.gz
better error message for 'owned'
-rw-r--r--compiler/semexprs.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index ef5315a61..820522f64 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -1519,7 +1519,8 @@ proc asgnToResultVar(c: PContext, n, le, ri: PNode) {.inline.} =
   # Special typing rule: do not allow to pass 'owned T' to 'T' in 'result = x':
   if ri.typ != nil and ri.typ.skipTypes(abstractInst).kind == tyOwned and
       le.typ != nil and le.typ.skipTypes(abstractInst).kind != tyOwned:
-    localError(c.config, n.info, "cannot return an owned pointer as an unowned pointer")
+    localError(c.config, n.info, "cannot return an owned pointer as an unowned pointer; " &
+      "use 'owned(" & typeToString(le.typ) & ")' as the return type")
 
 template resultTypeIsInferrable(typ: PType): untyped =
   typ.isMetaType and typ.kind != tyTypeDesc