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
An undemanded bare None resolves to whichever enum last declared a None variant, across modules #3088
Found under #3077. variant_type_ids is one table keyed by the bare variant name, written by every enum declaration in registration order (SemaDecl.w, the re-register loop after add_type), and a bare identifier with no demand reads it (SemaCheck.w, "Check enum variants", variant_type_ids.get(sym)). So the last enum to declare a None owns the bare name everywhere, the standard library's bodies included.
Within one module (spec is silent). This program is refused today:
enum Mode { None, Loud }
fn main:
let x = None
let y: Option[i32] = x // error: type mismatch in binding
and let x = None; x == Mode.None is true. The spec says .Member is the demanded enum's (§1.7, §9.7) and says nothing about a bare None beside a user enum's None. Law 1: a demand decides; with none, either Option's None is the prelude name the program imported (and Mode.None / .None spell the other) or the two meanings make it ambiguous and the programmer spells it. Either way the current answer, "the enum declared last", is neither.
Route: with analyze n1.w 'select:kind=ident,name~None' for the recorded type; the fix keeps one owner per visible scope (prelude + current module + imported variants via imported_variant_owners), never a foreign module's.
Activity
#3077: a body checked on demand starts in value position, and a retur…
#3088: an undemanded bare variant name resolves by scope, not by the …