Skip to content

Module privacy is enforced only when the entry file is named without a directory (check p1.w vs check src/p1.w) #1520

Closed

Description

@ehartford

Found while writing #1372's fixture. Stage2 of main f1e3bd2 (macOS; native Windows behaves the same). Whether §18.3 module privacy is enforced depends on how the entry file is spelled on the command line.

// src/cu.w
use c_import("<stdio.h>")
type Secret = i32
pub fn greet() -> str: "hi"

// src/p1.w
use cu
fn main:
    let s: Secret = 3
    print(f"{s} {greet()}")
invocation result
cd src && with check p1.w error: symbol 'Secret' is private to module 'cu.w'
with check src/p1.w (from the parent) ok
with check /abs/path/src/p1.w ok

The same holds with and without a with.toml in the parent. The same flip decides c_import scoping: use cu + let n: c_uint = 3 in a module with no c_import is "'c_uint' requires an explicit import" only in the first spelling, so a module sees another module's private C declarations whenever the entry path has a directory component. (It also hid #1372 from every invocation except the first.)

Expected: privacy is a property of the modules, not of the spelling of the entry path: Secret is private to cu.w in all three invocations. The likely route is a module-path mismatch between the root's recorded path and the imported module's (a dir/ prefix on one side), so the "same module" or "visible from current" test passes; not yet located at the line.

Activity

  1. added 20 commits that reference this issue on Sep 23, 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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions