Skip to content

use Sema from Lsp.w causes cascading false TypeId type errors #57

Closed

Description

@ehartford

Bug

Adding use Sema to src/Lsp.w causes 54 spurious "type mismatch" errors in Sema.w and SemaCheck.w, even though 22 other files already import Sema without issue.

Reproduction

Add use Sema to src/Lsp.w imports:

use Sema
use Compilation

Then make build produces errors like:

error: type mismatch in assignment
src/Sema.w:587:5
587 |     s.ty_i8 = s.add_type(TypeKind.TY_INT, 8, 1, 0)

error: type mismatch in assignment
src/SemaCheck.w:280:9
280 |         self.current_gen_yield_type = ret_type as TypeId

These are all TypeId (distinct i32) vs i32 mismatches. The same code compiles without errors when only the existing 22 files import Sema.

Expected

Adding another use Sema consumer should not cause type errors in unrelated files. The TypeId = distinct i32 type should be resolved consistently regardless of which files import the module.

Root Cause (suspected)

The module import merging changes declaration processing order when a new importer is added. The seed compiler's distinct type resolution is order-sensitive, causing false conflicts when the same module is imported from a different position in the dependency graph.

Workaround

Access sema data indirectly through comp.zcu.last_sema field access, and add helper methods to Sema.w that Lsp.w calls through the Zcu, avoiding a direct use Sema import.

Activity

  1. added a commit that references this issue on Jun 8, 2026
    54398ac
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