Skip to content

Gate-flip regression: basic HashMap usage fails with spurious "unknown type 'T'" in embedded std (test mode, not check-only) #572

Closed

Description

@ehartford

Found while fixing §3.8 test-corpus violations for #564, using the flipped-gate staged compiler (out/stage/bin/with-stage2, tree at 00422da4 + staged build).

The spurious "unknown type 'T'" diagnostics previously believed to be check-only artifacts also occur under with test, and the trigger is as small as the most basic HashMap usage:

fn main:
    let m = HashMap[str, i32].new()
    m.insert("a", 1)
    print(int_to_string(m.len()))
$ out/stage/bin/with-stage2 test repro.w
error: unknown type 'T'
 --> <embedded-std>/std/collections.w:21:22
21 |         var out: Vec[T] = Vec.new()
error: unknown type 'T'
 --> <embedded-std>/std/collections.w:47:49
47 | impl[T] Eq for Handle[T]:    fn eq(self: Handle[T], other:
...
error: test build failed

The pre-flip installed compiler passes the same file. A second trigger shape needs no HashMap in the test file at all: importing issue61_queries.receivers + issue61_queries.samples together makes test/behavior/lib/issue61_queries/generic.w's Cell.wrap(value: T) / Cell.get(self: Cell[T]) fail with the same "unknown type 'T'" (each module compiles fine in other combinations). A signature containing &HashMap[str, i32] is a third trigger.

Expected: generic decls in std/collections.w and sibling modules typecheck as before; HashMap usable.
Actual: spurious "unknown type 'T'" build failures.

Known-blocked positive tests (all pass with the pre-flip compiler, all §3.8 violations in them already fixed):

  • test/behavior/issue61_query_{feature_matrix,feature_matrix_dump_mir,local_vs_imported_equivalence,method_cache_keys,order_independent,state_stress,state_stress_dump_mir,string_lifetime_stress}.w
  • test/behavior/behav_hashmap.w, behav_hashmap_remove_option.w, behav_comptime_hashmap_*.w, behav_comptime_aggregate_freeze.w
  • test/behavior/behav_derive_soa_generic.w, behav_distinct_compat.w, behav_generic_distinct.w, behav_int_uint_aliases.w
  • test/behavior/issue59_imported_{query_matrix,builtin_queries_dump_mir,user_methods_dump_mir}.w, issue64_shared_receiver_reads.w
  • test/spec/spec_ss10_6_error_context.w, spec_ss13_2_hashmap_lookup_borrowing.w, spec_ss13_3_hashmap_convenience_methods.w

No test-side workaround exists or is appropriate; these tests should go green when this is fixed.

Activity

  1. ehartford commented on Jun 12, 2026

    @ehartford
    ContributorAuthor

    Fixed in 1f9ec56. Two independent triggers, both latent miscompiles in the stage that built the flipped compiler, not the gate itself: (1) the DiagnosticList Copy-handle conversion (now #576) — reverted; Zcu.init reads the list back through sema_seed.diags to satisfy §3.8; (2) lower_module returning Sema by value in a struct (now #577) — replaced with the MirLowerSemaBox field-place shape. The HashMap repro and all previously blocked issue61/hashmap/comptime tests pass on the landed commit.

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