Skip to content

Test files cannot import Mir-adjacent compiler modules (with test/run: unknown Sema methods) #688

Closed

Description

@ehartford

Found while adding test/internals/codegen_units_count_test.w (#681).

Repro: a test file with use compiler.CodegenUnits fails to compile under both with run and with test:

error: unknown method 'primitive_type_by_sym' for type '&Sema'
 --> src/Sema.w:1043:20
error: unknown method 'type_decl_source_path' for type '&Sema'
 --> src/Sema.w:1120:27
...
error: test build failed
 = stage: build

Expected: importing any compiler module from a test compiles, as it does for compiler.foundation.*, compiler.Link, compiler.ConanClient (all pass today).

Analysis: compiler.CodegenUnits pulls use Mir, whose graph reaches src/Sema.w. Sema's impl is split across sibling files (SemaCheck.w etc.); the compiler's own build assembles all of src/, but the per-use module graph walked for a test file misses the sibling impl files, so methods defined there are unknown. Shallow modules work; anything reaching the split-impl cluster breaks.

Workaround used (remove when fixed): pure decision policy extracted to leaf module src/compiler/CodegenUnitsPolicy.w so the internals test imports that instead of compiler.CodegenUnits.

Activity

  1. added a commit that references this issue on Jul 19, 2026
  2. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): does not reproduce. A program importing compiler.CodegenUnits compiles and runs from a tree with a current runtime root:

    use compiler.CodegenUnits
    print(1)
    
    $ with run main.w      # in a fresh worktree of main
    1
    

    (Run from a checkout whose out/bootstrap-lib is an older generation, the compiler refuses the stale runtime root by name, D30 #1815; that is the intended refusal, not this bug.)

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