Skip to content

Facade callback userdata: .Some(x) is "cannot infer the enum type" where Some(x) works #1765

Closed

Description

@ehartford

Spec: §16.2b.9 (a nullable callback's userdata is Option[&U]), §4 variant shorthand (.Variant when the type is known).

Repro (main and branch ruled-fixes; facade from test/behavior/behav_c_facade_callback_userdata_temporary.w):

d.exec(Some(on), .Some(Ctx { base: 7, label: "x".clone() }), 101)

Actual: error: cannot infer the enum type for .Some``. Some(Ctx { .. }) and `Option[&Ctx].Some(..)` work.

Cause: Sema.facade_prepare_callback_call checks the userdata argument with no expected type, because U is bound from that argument; a shorthand needs the expected enum. The parameter's shape is known before U is (Option[&U] for a nullable callback), so the shorthand could be checked against Option[_] and bind U from its payload.

Expected: .Some(x) is Some(x) here, as it is anywhere an Option is expected.

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