Skip to content

audit:resolution: a bare None in == records Sema type Option while MIR lowers Option[&T] #2385

Closed

Description

@ehartford

On main (92abde0), with analyze audit:resolution flags a None comparison against a view Option:

fn main:
    var xs: List[i32] = []
    print(f"{if xs.first() == None: "none" else: "some"}")

violation: resolution: main ... node kind 24: an expression lowered to an operand of another type (MIR Option[&i32], Sema Option) — the None literal's recorded Sema type is the bare generic Option base while MIR lowers the instantiated Option[&i32]. The D65 operand-type fact for a bare None under a comparison demand should be the demanded instantiation. Found while auditing the D117 fixtures; the same shape with List.first() reproduces it without any new code.

Activity

  1. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced.

    $ cat main.w
    fn main:
        var xs: List[i32] = []
        print(f"{if xs.first() == None: "none" else: "some"}")
    $ with analyze main.w audit:resolution
    violation: resolution: main at main.w:3:31 node 15342: an expression lowered to an operand of another type (MIR Option[&i32], Sema Option, node kind 24)
    resolution-audit: facts=19023 violations=1 FAILED
    

    post-release: an audit false positive on valid code; the program itself runs.

  2. added this to the post-v0.16.0 milestone on Oct 28, 2026
  3. ehartford commented on Nov 11, 2026

    @ehartford
    ContributorAuthor

    Does not reproduce on main 6ea2ec2: with analyze repro.w audit:resolution over the issue's program reports violations=0 ok (the None beside xs.first() is lowered at the Option Sema recorded). The view cousin (#3057) is fixed with a fixture in the current batch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions