Skip to content

A program alias named like a lazily-skipped std alias forces the std alias to resolve in the program's context ("unknown type" inside std.engines.mlib.defs); stage1 does not reproduce it #2575

Closed

Description

@ehartford

Two lines, checked with any self-built compiler since #2572 (main 8fda443, ~/.local/bin/with):

pub type multimap_s { pub root: *mut multimap_node_s = null, pub size: c_ulong = 0 }
pub type multimap_ct = [multimap_s; 1]
error: unknown type 'multimap_s'
 --> <embedded-std>/std/engines/mlib/defs.w:16:25
16 | pub type multimap_ct = [multimap_s; 1]

The std corpus std.engines.mlib.defs (reached by the prelude through std.collections since D151) declares multimap_ct = [multimap_s; 1], an alias over a record that lives in the corpus's harness unit (multimap.w), which no prelude closure loads; the alias is lazily skipped until a program names it. A program's own pub type multimap_ct makes it demanded (decl_iface_demanded, keyed by name), and resolve_deferred_non_generic_type_decls resolves the std alias with resolve_type_expr in the program's context, where multimap_s is the program's record: refused as not visible, reported as unknown at the std's line. The same happens for m_serial_read_t (declared in the sibling facade_shapes.w) and every alias a whole-program migration of M*LIB's test unit redeclares (tests/test-mbptree.c with m-string.h: 31 such errors, task of the Phase 4 test lane).

Expected: a std module's own reference resolves within its package (D100); a program's same-named declaration never changes what a std declaration means, and a lazily-skipped alias over a type that is not loaded stays skipped.

Stage divergence. Every seed-built stage1 (seed nightly-20261020-local-3) reports nothing on the repro; every self-built stage2/release binary (Phase 4's, facade-origins', mlib-tests') reports it. Both embed the same defs module (use std.engines.mlib.defs.multimap_ct resolves under both). A behavior that differs between the compiler the seed built and the one it built itself is a miscompile or undefined behavior in Sema on the way to the demand decision; hunt from Sema.resolve_deferred_non_generic_type_decl (decl 14541 in stage2 is never reached in stage1).

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