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
A non-pub method is callable from another module (§18.3) #2186
Spec §18.3: "pub exports names. No pub = module-private. Cross-module access to a non-pub symbol is a compile error; this applies uniformly to functions, types, constants, and globals."
// main.w
use lib1
let b = Box1 { n: 3 }
print(b.secret())
Expected: an error at b.secret() naming the non-pub method.
Actual: prints 3.
The stdlib relies on the hole. For example, BTreeMap.key_at is a non-pub helper over raw pointers that does no bounds check. User code can call it today: BTreeMap.new().key_at(0) segfaults (rc 139). Enforcing the rule needs an audit of the non-pub methods user programs and compiler-generated calls reach (debug_form, trait impl methods are exempt through the trait).
Ruled by D100 (spec v7.27, #2207): visibility is package-wide. A non-pub method is visible throughout its package and refused from another package; a module under an internal path is importable only from its parent's tree; fields follow the same rule; unchecked helpers like BTreeMap.key_at become unsafe fn.
Activity
ehartford commentedon Oct 6, 2026
Ruled by D100 (spec v7.27, #2207): visibility is package-wide. A non-pub method is visible throughout its package and refused from another package; a module under an
internalpath is importable only from its parent's tree; fields follow the same rule; unchecked helpers like BTreeMap.key_at becomeunsafe fn.D100: package-wide visibility, internal paths, method privacy (#2186) (…