writeonce/compiler/test/golden/bc/elision.wo
shoney.arickathil 2379a95016 feat(compiler): remove @gc from the language — GC-ness is fully inferred (7b)
`@gc` is no longer part of the language: a developer never writes or mentions
it. GC-ness is decided entirely by inference (structural cycles + demand
promotion), which the earlier 7b commits made complete and precise.

- parser: `@gc` on a class is now WO-E104 ("GC-ness is inferred; run
  `woc --dump-gc`. Remove it."). `is_gc` stays false; the class classifies by
  inference. No `.wo` in the repo carries `@gc` anymore.
- types.ml: retired the WO-W201 machinery (suggest_gc_annotation,
  has_recursive_structure(_type), has_unique_field, gc_suggestion_code) — it
  suggested `@gc`, now obsolete since inference traces exactly those classes.
- runner.ml: deleted the 8 WO-W201 gc-suggestion test blocks; the @gc-exemption
  test's `Cache` is made self-referential so inference classifies it gc without
  an annotation.
- fixtures: dropped `@gc` from rc.wo (Cache demand-promotes via its escape),
  elision.wo (Cache given a self-ref to stay structurally gc for the rc-elision
  dump), pricing-demo.wo (PriceCache doesn't escape -> now owned), and the
  abandoned-cycle/budget-steps corpus (Node is structurally gc). rc.wo keeps a
  placeholder comment line so its line-indexed rc assertions hold. Goldens
  re-blessed.
- docs: error catalog gains WO-E104 and marks WO-W201 retired; gc-cycle README
  records the keyword removal.

Verified: woc-test 553/0 (was 566 minus the 13 retired WO-W201 checks),
test_diag 14/0, oop-e2e 79/0, employee 8/0, log-watcher 7/0. `git grep '@gc'`
finds only comments — success criterion 1 met.

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

32 lines
856 B
Text

-- The zero-cost-when-provable promise, as a pinned dump.
--
-- `proven` aliases a @gc reference out of a field and hands it to a
-- function that only reads it. The owner pass proves the acquire and its
-- release balanced inside one scope (compiler/test/golden/owner/rc.wo
-- pins that as ELIDED), and nothing about the access is unprovable, so
-- the emitted body must contain NO borrow op and NO rc op at all — the
-- disassembly below is the evidence. `main` is the contrast: an escape
-- into a field is a KEPT acquire, so RC_INC does appear there.
class Cache {
hits: Int
peer: ?Cache
}
class Holder {
cache: Cache
}
fn read(c: Cache) -> Int {
return c.hits
}
fn proven(h: Holder) -> Int {
let c = h.cache
return read(c)
}
fn main() {
let cache = Cache { hits: 41 }
let h = Holder { cache: cache }
print_int(proven(h) + 1)
}