Skip to content

compiler: fail closed before codegen when unresolved or dropped types survive type checking #789

@slepp

Description

@slepp

Summary

I want the checker -> serializer -> codegen boundary to fail closed when type information is incomplete, instead of degrading into warnings, omitted expression-type entries, or MLIR fallback behavior.

Why

A few current seams point at the same foundation gap:

  • type checking does not appear to guarantee that every surviving expression type is free of unresolved inference variables
  • serializer enrichment can drop unconvertible expression types and keep going
  • MLIR lowering still has fallback paths when type metadata is missing

We already fixed narrower cases like the old range warning in #264, but the broader issue is that lowering-relevant type facts are not mandatory all the way through the pipeline.

What I want

  • if an unresolved inferred type survives past type checking, the compiler should reject it before codegen
  • if enrichment cannot serialize a lowering-relevant type, that should be a hard compiler error rather than a best-effort omission
  • missing expression-type metadata should be treated as a compiler bug or fail-closed condition at the lowering boundary, not a cue to rediscover type truth heuristically

Scope

This is not a request to redesign the type system. I want a narrower foundation pass that tightens the fail-closed boundary between hew-types, hew-serialize, and hew-codegen.

Acceptance shape

If this gets picked up, I would expect:

  1. one explicit invariant for what must be fully resolved before serialization/codegen
  2. targeted tests that prove unresolved type holes do not reach MLIR/LLVM
  3. fewer silent drops and sentinel fallbacks in the lowering path

Related

This is related to the narrower range warning that was previously tracked in #264, but it is meant to cover the broader checker-to-codegen contract.

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