Skip to content

?? refuses a view of an Option (xs[i] ?? 0 on a List[Option[i32]]): D22 says ?? is transparent to view origins #2524

Closed

Description

@ehartford

On main 8182ccf (installed v0.15.3.0-g8182ccfb1):

fn main:
    let v: List[Option[i32]] = [Some(8)]
    print(f"{v[0] ?? 0}")          # error: ?? operator requires an Option or Result with a single success payload
    let e = v[0]
    print(f"{e ?? 0}")             # the same

v[0] is the element place (D27) and binds a view, &Option[i32]; ?? refuses the view. D22 §21.1 and the d22-Eric-Ruling say Option, Result, patterns, ?, ?? and the eliminators are transparent to view origins, so ?? on a &Option[i32] is a ?? on the Option it views, yielding the payload (a Copy i32 here; a view of it for an owning payload). Found writing the D103 element-site fixture (behav_d103_site_element.w reads the element with .unwrap() until this is fixed).

Activity

  1. ehartford commented on Oct 23, 2026

    @ehartford
    ContributorAuthor

    Fixed on main (b050a01, PR #2587, stack #2588): one commit with the fixture test/behavior/behav_2524_default_through_option_view.w, which failed before the fix and passes after; battery GREEN on the stack top 077d684 (669 s, pinned seed nightly-20261023-local-1).

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