Skip to content

A module's own global is shadowed by a bare variant name of an enum an imported module declares #3068

Closed

Description

@ehartford
// flagsmod.w
pub enum Flags:
    BEFORE
    AFTER
// main.w
use flagsmod
let AFTER = "expected text"
fn main:
    print(f"{AFTER}")
BUG: a `&str` runtime argument is not a str value (LLVM type kind 8) [src/CodegenDispatch.w:18342 Codegen.str_view_arg]

with check main.w --dump-typed types the global as let AFTER: str, but the use resolves to Flags.AFTER (an integer), in an f-string, in assert, and as an assert_eq argument (there it printed != "16384" when the enum was FnFlags). A pub const AFTER: i32 in the imported module does not shadow the global; only an enum's bare variant name does (SemaDecl.w registers every variant under its bare name in variant_lookup, lines ~1354 and ~1469, and the identifier path consults it ahead of the module's own declaration). §18.2 / D70: a module's own declaration beats anything an import brings in. Found 2026-11-08 writing test/internals/ceremony_fix_test.w with globals named BEFORE and AFTER while importing the compiler's modules (FnFlags.AFTER = 16384).

Activity

  1. added
    bug
    on Nov 7, 2026
  2. added a commit that references this issue on Nov 7, 2026
  3. added a commit that references this issue on Nov 7, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions