Skip to content

Conversation

@hargoniX
Copy link
Contributor

This PR allows projections on tagged values in the IR type system.

While executing this branch of code should indeed never happen in practice, enforcing this through
the type system would require the compiler to always optimize code to the point where this is not
possible. For example in the code:

cases x with
| none => ....
| some =>
    let val : obj := proj[0] x
    ...

static analysis might learn that x is always none and transform this to:

let x : tagged := none
cases x with
| none => ....
| some =>
    let val : obj := proj[0] x
    ...

Which would be type incorrect if projections on tagged were illegitimate. However, we don't want
to force static analysis to always simplify code far enough on its own to enforce this invariant.

@hargoniX hargoniX requested a review from leodemoura as a code owner December 10, 2025 13:19
@hargoniX hargoniX added the changelog-compiler Compiler, runtime, and FFI label Dec 10, 2025
@hargoniX hargoniX enabled auto-merge December 10, 2025 13:19
@hargoniX hargoniX added this pull request to the merge queue Dec 10, 2025
Merged via the queue into master with commit 7219616 Dec 10, 2025
19 checks passed
@hargoniX hargoniX deleted the hbv/ir_typecheck branch December 10, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-compiler Compiler, runtime, and FFI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants