Skip to content

Codegen BUG on an Option module global read in main: let a: Option[i32] = None + if a.is_none() → "discriminant rvalue 0: place 0 has no type in main" #2976

Closed

Description

@ehartford

Found implementing D184 (script bindings become globals); reproduces on main's own compiler (v0.16.0.8-gd2fe55dbf):

let a: Option[i32] = None
fn main:
    if a.is_none(): print("none")
error: code generation failed: BUG: discriminant rvalue 0: place 0 has no type in `main`

let a: Option[i32] = None alone, or print(a < b) over two such globals, compiles; the is_none() (a discriminant read of the global's place) in main does not. Route: with analyze repro.w audit:resolution (the operand-type check), then --dump-mir main for the discriminant rvalue's place and --explain-mir-origin. Test behav_d97_option_none_first becomes this shape under D184 and fails on it.

Activity

  1. added
    bug
    crash
    on Nov 2, 2026
  2. added a commit that references this issue on Nov 7, 2026
  3. ehartford commented on Nov 7, 2026

    @ehartford
    ContributorAuthor

    Fixed in #3056 (merged as afbdbb1).

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

    bugcrash

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions