better error message for 'owned'
This commit is contained in:
parent
9a9c002abe
commit
e0437dfec4
1 changed files with 2 additions and 1 deletions
|
|
@ -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':
|
# 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
|
if ri.typ != nil and ri.typ.skipTypes(abstractInst).kind == tyOwned and
|
||||||
le.typ != nil and le.typ.skipTypes(abstractInst).kind != tyOwned:
|
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 =
|
template resultTypeIsInferrable(typ: PType): untyped =
|
||||||
typ.isMetaType and typ.kind != tyTypeDesc
|
typ.isMetaType and typ.kind != tyTypeDesc
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue