Class CloseableSlotStoreOrError

java.lang.Object
org.ek9lang.compiler.phase5.CloseableSlotStoreOrError

final class CloseableSlotStoreOrError extends Object
THE fresh-store rule for closeable SLOTS (R-A, Steve 2026-10-06, decisions D3 and D9, with R-D): every closeable object has exactly ONE owner, so a closeable value may enter a slot that will close it only when nothing else already owns it.

The slots are a closeable PROPERTY (its type's operator close closes it) and a try-with-resources RESOURCE (the try closes it). A local is E81056, the returning variable E81057, a slot of a non-closeable type E81059; a dynamic construct's capture is decided with the capture-ownership rule (R-E). For a StoreSite whose slot and value are both closeable (CloseableResourceToBeChecked.isManagedCloseableType(ISymbol)):

  • E81062 - the value must be NEW, as IsFreshValueExpression.forCloseableReturns(Function) reads it (a constructor call, or a call whose declaration returns a new closeable). A constructor's own parameter stored in one of its properties is the one exception: that is a TRANSFER, and every construction must then hand the parameter a new value (CloseableArgumentKeeping, the R4 half). A parameter transferred twice has two owners and is the same error.
  • E81063 - a closeable SLOT is assigned once (D3, extended 2026-10-06 from properties to every closeable slot). A closeable property is set in its own initialiser or in its own type's constructor, on the object being constructed, while it holds nothing yet. A closeable RETURNING variable (of a function, method, operator, dynamic function, or a switch/try/while/for expression) that is initialised at its declaration is never assigned again, and one declared unset (<- rtn as Res?) is assigned at most once on any path. A try-with-resources RESOURCE is never assigned again: its try closes only what it then holds. Any other assignment (:=, :, =, :=?) re-points the slot and drops what it held: :=? too, because a closeable that failed or closed is present but unset, and the guard replaces it without closing it. "May already hold" is the MUST-set path state plus SlotAssignedOnce, its MAY half (a value set on some paths, or in a loop body).
  • E81064 - closeable properties are closed in reverse DECLARATION order, which is reverse ACQUISITION order only when a constructor acquires them in declaration order: setting one while a closeable property declared after it already holds a value (its initialiser ran, or this path set it) is an error.

Injected properties (x as T!) belong to the application that registered them and are never assigned.

  • Constructor Details

  • Method Details

    • accept

      void accept(EK9Parser.VariableDeclarationContext ctx, boolean isTryResource)
      A declaration with an initialiser: a property's initialiser, or a try-with-resources resource.
    • accept

      A pointer assignment to a variable or property.
    • acceptConstruction

      void acceptConstruction(EK9Parser.CallContext ctx)
      Every argument of a construction that is a closeable value but not a new one: the constructor may keep it (decided after every source is walked), and a constructor passing on its own parameter keeps what the constructor it calls keeps.