Summary
The host type checker still has two live correctness gaps in expression checking:
- typed expressions return the annotated type without verifying that the value matches it
- constructor expressions still have TODO-level handling for enum variant lookup and field ordering
These paths sit in active checking logic, so they can permit incorrect programs or reject valid ones depending on the input shape.
Why this matters
- incorrect acceptance/rejection at the typechecker layer undermines compiler trust
- these gaps affect core expression semantics, not optional tooling
- both issues are small enough to batch into one focused fix
Current behavior
Examples from the current implementation indicate:
TypedExpr returns the annotation after checking the value, but does not enforce compatibility
- constructor checking still treats named-field construction as a tuple-shaped placeholder instead of validating the target variant and field order
Expected behavior
- typed expressions should validate that the value conforms to the annotated type
- enum constructor expressions should resolve the target variant and validate field names/order/payload shape correctly
Suggested scope
- add regression tests for invalid typed expressions and enum constructor mismatches
- implement type compatibility checks for
TypedExpr
- implement proper enum variant lookup and constructor field validation
Acceptance criteria
- invalid typed expressions fail with clear diagnostics
- invalid enum constructor field shapes fail with clear diagnostics
- valid typed expressions and valid enum constructors continue to pass
- targeted regression tests cover both code paths
Summary
The host type checker still has two live correctness gaps in expression checking:
These paths sit in active checking logic, so they can permit incorrect programs or reject valid ones depending on the input shape.
Why this matters
Current behavior
Examples from the current implementation indicate:
TypedExprreturns the annotation after checking the value, but does not enforce compatibilityExpected behavior
Suggested scope
TypedExprAcceptance criteria