Skip to content

A module under lib/std/<parent>/ cannot see a corpus pub let through use; generic types need item imports #1136

Closed

Description

@ehartford

Two visibility gaps for a stdlib module placed under a parent module directory (lib/std/collections/binary_heap.w, imported as std.collections.binary_heap; the parent lib/std/collections.w exists and is prelude-imported):

  1. use std.c_algorithms.defs (a whole-module import) does not make the corpus's pub let BINARY_HEAP_TYPE_MAX: c_uint = 1 visible: error: undefined variable. The item import use std.c_algorithms.defs.BINARY_HEAP_TYPE_MAX does not either. The identical file copied to lib/std/binary_heap_probe.w (top level) checks clean, and a user program at the project root sees the global through both spellings.

  2. use std.collections.engine_slot (whole-module) does not bring the generic type pub type Slot[T] { ... } into scope (unknown type 'Slot') while the same import does bring the module's functions (slot_compare); the item import use std.collections.engine_slot.Slot works. Non-generic types from std.c_algorithms.defs (_SortedArray, c_uint) resolve through the whole-module import in the same file.

Repro: the c-algorithms-phase1 worktree, out/bootstrap/bin/with-stage1 check lib/std/collections/binary_heap.w with the globals spelled as in lib/std/c_algorithms/defs.w. The facades currently spell the heap type as a local constant and import Slot by item as the workaround; remove both when this is fixed.

Spec: §18 module imports (a whole-module use brings every pub item of the module).

Activity

  1. ehartford commented on Oct 24, 2026

    @ehartford
    ContributorAuthor

    No longer reproduces (main 23dd9db): a module under lib/std/collections/ importing std.engines.c_algorithms.defs and std.collections.engine_slot through whole-module uses sees the corpus pub let and the generic type. #2614 removed BinaryHeap's workaround (the local HEAP_TYPE_* constants); the facade reading BINARY_HEAP_TYPE_MIN/MAX is the standing regression test since std compiles in every battery.

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