You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
D34-A: demand-site finalization — a Builder satisfies an owned demand for its built type; grander wrapper-elimination design goes to Eric #920
Ruling: docs/decisions.md D34 ('A should apply to all Builder patterns (or maybe something grander, maybe any form of wrapper like an Option or a Promise)').
At an owned-demand site — return position against a declared type, typed binding, argument to a typed param — a value whose type declares a canonical finalization to the demanded type satisfies the demand implicitly: a StringBuilder tail satisfies -> str without .to_str(). Mechanism sketch: a trait (working name Build[T]/Realize[T]: move fn realize() -> T) consulted by the demand-adjustment path D22 already runs (contextual materialization is precedent — this extends 'an annotation demands what it says' from views to finalizable wrappers). Finalization CONSUMES the wrapper; the transfer-is-explicit tension is accepted per the ruling — consuming a builder at a demand site is the builder's purpose.
Note the D34-C interaction: once ++ is efficient (#919) the StringBuilder case mostly evaporates; phase 1 still matters for every OTHER builder-pattern type (config builders, the derive(Builder) machinery, request builders).
Phase 2 (design brief REQUIRED before any implementation): the grander scope
Eric's 'any form of wrapper — Option or a Promise' generalizes to demand-driven ELIMINATION:
Option[T] satisfying a T demand = implicit unwrap ⇒ implicit PANIC on None — a silent partial operation at every annotated site; interacts with D22's rule that eliminators are view-transparent.
Result[T,E] = implicit ? or implicit unwrap — two different semantics to choose between.
Each arm changes where programs can panic/suspend without a token in the source. The brief must lay out per-wrapper semantics, reference comparisons (Rust rejects all of these; Swift's implicit-unwrap optionals are widely considered a mistake; Kotlin/Scala implicit conversions cautionary tales), and a committed recommendation. No implementation past phase 1 until Eric blesses the specific arms.
Spec impact: normative wording for the demand-site rule (Eric's words only, per doctrine).
Triage 2026-10-25, with v0.15.3.0 (main a261b65): still reproduces. A builder in a position that demands its built type is refused, and the error points at the binding rather than the return:
use std.string.StringBuilder
fn make() -> str:
var b = StringBuilder.new()
b.push_str("hi")
b
error: return type mismatch
--> main.w:3:5
3 | var b = StringBuilder.new()
post-release: phase 1 is a new demand-site rule in Sema; until it lands the user writes the finalizing call. (Its relation to D111's builder sentence is asked on #919.)
Activity
ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): still reproduces. A builder in a position that demands its built type is refused, and the error points at the binding rather than the return:post-release: phase 1 is a new demand-site rule in Sema; until it lands the user writes the finalizing call. (Its relation to D111's builder sentence is asked on #919.)