Module visibility
Design document · Original source
RFCs record designs and changes. A proposal appearing here does not mean its feature is ready to use. Explore current language support
Status recorded in the original: Tooling experimental
Bound original source · SHA-2567b04c505f91a0d970545ec6820bcd4c3c638da58014515706ae26ef1d2a82cea
Status: tooling experimental Target line: N/M 0.2 Last updated: 2026-07-13
Problem
N/M 0.1 workspace imports expose every top-level circuit, observable, and const. A module cannot keep implementation helpers private, so workspace, LSP, and package boundaries cannot share one explicit export contract.
Proposed syntax
module bell_library;
private const HALF = PI / 2;
private circuit prepare_phase(data: QReg<2>) {
Ry(data[0], HALF);
}
public circuit prepare_bell(data: QReg<2>) {
H(data[0]);
CNOT(data[0], data[1]);
}
public observable parity = Z(data[0]) Z(data[1]);The negotiated tooling slice accepts public and private only on circuit, observable, and const. fn main, param, executable statements, annotations, and nested declarations cannot carry visibility.
Compatibility
- N/M 0.1 source remains unchanged: unqualified declarations are treated as legacy-public.
- The stable parser default rejects visibility syntax with
NM-PARSE-051unlessexperimental.moduleVisibilityis explicitly enabled. - With the flag enabled, private declarations remain available inside their source module but are excluded from
use workspace.<module>expansion. - CLI callers negotiate with
--experimental-module-visibility; Language Server and VS Code callers useinitializationOptions.nm.experimental.moduleVisibility=true. Neither surface silently enables the proposal. - Local document symbols include private declarations. Cross-module completion, workspace symbols, definition, signature help, references, prepare-rename, and rename filter them from consumers.
- Future source-version negotiation may change the default only in a new language contract; this RFC does not do so.
Non-goals in this slice
- Package publication exports or cryptographic access control. Visibility is a language namespace boundary, not a security boundary.
- Re-export syntax, wildcard imports, friend modules, package namespaces, or registry version syntax.
- Visibility for local variables, parameters,
fn main, tests, properties, or snapshots.
Promotion sequence
Parser flag and AST evidence → workspace semantic filtering → CLI/LSP/VS Code parity → cross-platform conformance fixtures → 0.2 preview evaluation. The first three stages are implemented. Promotion remains blocked on the Windows/Linux Node 20/22 matrix and later package-publication design; the 0.1 golden parser/runtime suite must remain unchanged throughout.