writeonce/compiler/test/golden/owner-err/borrow-escape.wo
shoney.arickathil 023233895c test(compiler): unit helpers run inference; retarget borrow-escape fixture
Wire Gcinfer.infer into runner.ml's owner_str/emit_str so the unit tests
classify GC-ness identically to the driver (prerequisite for removing @gc: its
tests read the golden .wo through the library).

That exposed owner-err/borrow-escape.wo, which tested WO-E304 on *class*
escapes — now legally demand-promoted. Retargeted it to CONTAINER (`multi Text`)
escapes, which are owned and never promoted, so it still exercises the three
WO-E304 shapes (stored-in-field, returned, moved-to-take). Assertion positions
+ golden re-blessed.

Verified: woc-test 566/0, test_diag 14/0, oop-e2e 79/0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 19:10:39 +02:00

23 lines
566 B
Text

-- Iteration 7b: WO-E304 borrow escapes, using CONTAINER values (`multi Text`).
-- A class value that escapes is demand-promoted to traced, so the illustrative
-- escapes must be containers, which are owned and never promoted. Mirrors the
-- run/borrow-escape-return corpus case (a class escape, now legal).
class Holder {
items: multi Text
fn adopt(other: multi Text) {
self.items = other
}
}
fn keep(take b: multi Text) -> Int {
return 0
}
fn leak(h: Holder) -> multi Text {
return h.items
}
fn stash(h: Holder) -> Int {
return keep(h.items)
}