You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type.from_int(n) returns Option[repr] instead of Option[Type] (§4.4a) #1453
Spec: §4.4a ("Conversion:Type.from_int(n) converts an integer to Option[Type], returning .None for values that don't match any defined discriminant: let c = Color.from_int(2) // Some(Color.Green)").
enum Color: i32:
Red = 1
Green = 2
fn main:
let c: Option[Color] = Color.from_int(2)
match c:
Some(.Green) => print("green")
_ => print("other")
error: type mismatch in binding
--> fromint.w:6:5
from_int is typed Option[i32] (the repr) instead of Option[Color]; with a u32 repr it is Option[u32] (print(K.from_int(3000000000)) fails "type 'Option[u32]' does not implement trait 'Display'").
Expected: Option[Color], printing green.
Found while exhausting the #1444 matrix (installed nightly-20260922-local-1-8c859a7d0559).
Activity
MIR/codegen: a discriminant enum's discriminant is a value of its rep…
MIR/codegen: a discriminant enum's discriminant is a value of its rep…
Sema: Type.from_int(n) is an Option[Type] (#1453)
Sema: Type.from_int(n) is an Option[Type] (#1453)
Sema: Type.from_int(n) is an Option[Type] (#1453) (#1541)
ehartford commentedon Sep 26, 2026
Verified fixed on main 55739d4 (release binary): Color.from_int(2) is Some(.Green).