From 08e9514c1d6b02d5563a97f2bd5d08bf83eebd93 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 22 Jun 2026 16:13:14 +0200 Subject: [PATCH] added missing test file --- tests/ic/mmethupref.nim | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/ic/mmethupref.nim diff --git a/tests/ic/mmethupref.nim b/tests/ic/mmethupref.nim new file mode 100644 index 0000000000..862408b123 --- /dev/null +++ b/tests/ic/mmethupref.nim @@ -0,0 +1,23 @@ +# Helper for tmethupref: a `{.base.}` method whose body contains a closure +# iterator that in turn contains a nested closure capturing a method-local. +# The capture forces an `up` reference chain (nested closure -> iterator env -> +# method env). The method also gets a dispatcher (a `copySym` clone that shares +# the method's body sub-tree, including the iterator). Under `nim ic` the +# dispatcher used to be treated as an owned runtime routine and lambda-lifted in +# the per-module lower stage, lifting the SHARED iterator a second time under a +# different owner identity -> "up references do not agree" / "could not determine +# closure type". See nifbackend.ownsRuntimeRoutine (sfDispatcher exclusion). + +type Base* = ref object of RootObj + val*: int + +method compute*(b: Base): int {.base.} = + var acc = b.val + iterator steps(): int {.closure.} = + proc bump() = + acc += 1 + bump() + bump() + yield acc + for s in steps(): + result = s