diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 11743499d7..fb205110e6 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -279,7 +279,7 @@ proc ccgIntroducedPtr(conf: ConfigRef; s: PSym, retType: PType): bool = result = false # first parameter and return type is 'lent T'? --> use pass by pointer if s.position == 0 and retType != nil and retType.kind == tyLent: - result = true + result = pt.kind != tyVar proc fillResult(conf: ConfigRef; param: PNode) = fillLoc(param.sym.loc, locParam, param, ~"Result", diff --git a/tests/lent/tlent_from_var.nim b/tests/lent/tlent_from_var.nim new file mode 100644 index 0000000000..c8a15b1a13 --- /dev/null +++ b/tests/lent/tlent_from_var.nim @@ -0,0 +1,14 @@ +discard """ + output: "x" +""" + +# bug #14805 + +type Foo = object + a: string + +proc bar(f: var Foo): lent string = + result = f.a + +var foo = Foo(a: "x") +echo bar(foo)