diff --git a/compiler/typeallowed.nim b/compiler/typeallowed.nim index 80b532371c..05584341b6 100644 --- a/compiler/typeallowed.nim +++ b/compiler/typeallowed.nim @@ -99,12 +99,13 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind, if isInlineIterator(typ) and kind in {skVar, skLet, skConst, skParam, skResult}: # only closure iterators may be assigned to anything. result = t - let f = if kind in {skProc, skFunc}: flags+{taNoUntyped} else: flags + let innerFlags = flags - {taObjField, taTupField, taIsOpenArray} + let f = if kind in {skProc, skFunc}: innerFlags+{taNoUntyped} else: innerFlags for _, a in t.paramTypes: if result != nil: break - result = typeAllowedAux(marker, a, skParam, c, f-{taIsOpenArray}) + result = typeAllowedAux(marker, a, skParam, c, f) if result.isNil and t.returnType != nil: - result = typeAllowedAux(marker, t.returnType, skResult, c, flags) + result = typeAllowedAux(marker, t.returnType, skResult, c, innerFlags) of tyTypeDesc: if kind in {skVar, skLet, skConst} and taProcContextIsNotMacro in flags: result = t diff --git a/tests/lent/tlents.nim b/tests/lent/tlents.nim index 28fe0602ed..1b14972239 100644 --- a/tests/lent/tlents.nim +++ b/tests/lent/tlents.nim @@ -23,3 +23,25 @@ block: doAssert x(a) == 1 doAssert y(a) == 1 + +import std/tables + +block: + type + R = proc(): lent O {.nimcall.} + F = object + schema: R + O = object + fields: Table[string, F] + + func f(o: O, key: string): R = + if key in o.fields: o.fields[key].schema + else: nil + +block: + type + R = proc(): lent O + O = object + r: R + + func f(o: O): int = 42