Issue #97: What is left of a type that holds itself (patterns through a box, guards, null without allocation)

Open and answer this issue on GitHub.

language, note · opened 2026-09-30 · updated 2026-10-06 · 2 comments

Record: ADR-246 D5. D1-D4 are built (tests/recursive_types.rs); three refinements are not, in this order:

  1. A pattern that looks inside a boxed part (Expr::Add(Expr::Num(n), b), NK1193 today) rewritten into a match in the arm.
  2. A guard that reads a boxed binding before the arm opens it.
  3. A nullable field boxed inside its option, so a null costs no allocation.

Comments

keywan-ghadami, 2026-10-01

Item 1 is built in #289 (0.0.306).

A pattern now looks inside a boxed part one level deep. Such an arm is lowered with a guard (matches! over nikaia_std::boxed::peek) and a let … else in the arm, and like a guarded arm it covers no variant on its own (NK1151).

These are still NK1193, each by name: a box inside that part, an | alternative, and a guard that reads a name bound in there.

Left: item 2 (a guard reading a boxed binding as the box; a name used only in the guard is also opened in the body and warned about as unused) and item 3 (Option<Box<T>>).


Generated by Claude Code

keywan-ghadami, 2026-10-01

Item 2 was built in #307 (0.0.317):

Item 3 (Option<Box<T>> for a nullable field) is what remains.


Generated by Claude Code

Back to Open Issues