Skip to content

extern var resolves an untyped owner global in another module but calls a typed one 'not visible' (§18, D100) #2335

Closed

Description

@ehartford

Spec: D100 (no pub = package-wide), §16 extern var, #113.

Repro (three files in one directory, as test/behavior/issue113_extern_var_*.w):

owner.w

var issue113_shared_counter: i32 = 41

ref.w

extern var issue113_shared_counter: i32
pub fn issue113_read_shared() -> i32: issue113_shared_counter

main.w

use issue113_extern_var_owner
use issue113_extern_var_ref
fn main:
    assert(issue113_read_shared() == 41)
    print("ok")

Expected: the same result whether the owner's global is typed or not. The untyped owner (var issue113_shared_counter = 41) merges with the extern var (the #113 regression test).

Actual (installed compiler and D114 stage1 alike), with the owner typed:

error: symbol 'issue113_shared_counter' is not visible from this module
 --> issue113_extern_var_ref.w:7:5

The typed and untyped owners take different resolution paths (the owner fixture's comment names "the frontend's extern-var decl filter"). One of the two answers is wrong for a package-wide global. Found during the D114 sweep (#2327); not caused by it.

Activity

  1. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

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

    $ cat issue113_extern_var_owner.w
    var issue113_shared_counter: i32 = 41
    $ cat issue113_extern_var_ref.w
    extern var issue113_shared_counter: i32
    pub fn issue113_read_shared() -> i32: issue113_shared_counter
    $ with run main.w
    error: symbol 'issue113_shared_counter' is not visible from this module
     --> issue113_extern_var_ref.w:2:39
    

    With the owner untyped (var issue113_shared_counter = 41) the same program now stops on a different, correct error: the literal defaults to isize (D114), and returning it as i32 needs a cast.

    post-release: extern var naming a With global in another module is rare, and D100 already makes a non-pub global visible package-wide.

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions