Skip to content

Codegen-Restriction Errors Misplaced in Type Checker #176

@0xGeorgii

Description

@0xGeorgii

ArrayLiteralAsArgument and ArrayReturnCallInExpressionPosition are not type errors — the types are valid in both cases. They are codegen lowering restrictions: the sret calling convention requires a destination pointer (only available from a named variable),
and array literal arguments need a named frame slot.

These belong in core/analysis/ (the analyze() pass), which already documents its scope as "semantic violations that are not type errors" (see core/inference/src/lib.rs line 518-523). The analyze() function is currently a no-op stub.

  • Move when: core/analysis/ crate is created (likely alongside return-path analysis, which is already tracked as a known issue)
  • Current locations:
    • ArrayLiteralAsArgument: core/type-checker/src/errors.rs line 448, checked at 3 argument validation sites in type_checker.rs
    • ArrayReturnCallInExpressionPosition: core/type-checker/src/errors.rs line 458, checked at 6 sites in type_checker.rs
  • Why it works today: The type checker runs before codegen, so catching these early is functionally correct. The issue is architectural — it couples the type checker to codegen implementation details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions