Skip to content

Implicit Some: a value converts to Option[T] where one is expected (decide before stable) #2217

Closed

Description

@ehartford

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).

Activity

  1. ehartford commented on Oct 6, 2026

    @ehartford
    ContributorAuthor

    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.

  2. added a commit that references this issue on Oct 8, 2026
    086bd94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions