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
Implicit Some: a value converts to Option[T] where one is expected (decide before stable) #2217
Deferred from D102 (Eric, 2026-10-06), with an expected answer of yes. Wrapping a value where an Option is expected has exactly one meaning, which is the mission's test for letting the compiler do it; Swift and Kotlin both do it. It is the ergonomic cost D102 introduces: setting a C callback field becomes s.zalloc = Some(my_alloc). Decide before the stable release, as its own change across every Option site (arguments, fields, returns, bindings), not a C-only rule. Today take(twice) against take(f: Option[extern "C" fn(i32) -> i32]) is refused (wrong argument type).
Ruled (Eric, 2026-10-07): yes. Spec §4.9a: where Option[T] is demanded and the expression has type T, it is Some(expression); None and an existing Option pass unchanged; once, at the demand, never where nothing is demanded; the conversion does not participate in inference (fires only once the demanded type is known). Demand propagates into if/match arms and block tails as it already does; operator operands are not demand sites. Decision D103. Implementation pending; the compiler is non-compliant until it lands.
Activity
ehartford commentedon Oct 6, 2026
Ruled (Eric, 2026-10-07): yes. Spec §4.9a: where
Option[T]is demanded and the expression has typeT, it isSome(expression);Noneand an existingOptionpass unchanged; once, at the demand, never where nothing is demanded; the conversion does not participate in inference (fires only once the demanded type is known). Demand propagates into if/match arms and block tails as it already does; operator operands are not demand sites. Decision D103. Implementation pending; the compiler is non-compliant until it lands.D103, D104: value-to-Option conversion (§4.9a); comptime-callability …
D102: extern "C" fn is non-null; nullable C function pointers are a p…
D102: non-null extern fn; nullable C function pointers as pointer-siz…
D103: a value converts to Option[T] where one is demanded (§4.9a) (wi…