Skip to content

Generic declaration validation rejects private types from its own module #1130

Closed

Description

@ehartford

Specification §18.3 makes unexported names module-private. A generic declaration must be able to refer to private types in its own module.

Minimal reproduction, lib/hidden.w:

type Entry[T] { value: T }
pub type Container[T] { entry: *mut Entry[T] }

main.w:

use hidden
fn main: print("ok")

with check --prelude=core main.w should succeed. It instead reports unknown type 'Entry', suggests Entry, and attributes the declaration error to the importing main file.

Native LLDB stops at Sema.emit_unknown_type_error from Sema.validate_type_expr_with_impl_type_params, then Sema.validate_generic_type_decls. In src/SemaDecl.w:2957, the declaration-validation loop visits each generic type without installing that declaration's source context before the visibility check at line 2782. This differs from ordinary declaration/body checking through update_decl_source_context.

Found while implementing an owning c-algorithms heap facade with a private generic node type. No workaround: the node stays private. Fix and regression coverage are being prepared in the Phase 1 branch, including checking that the private type remains inaccessible from the importer.

Activity

  1. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): does not reproduce.

    $ cat lib/hidden.w
    type Entry[T] { value: T }
    pub type Container[T] { entry: *mut Entry[T] }
    $ cat main.w
    use hidden
    fn main: print("ok")
    $ with check --prelude=core main.w
    ok
    
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