Skip to content

Commit 5ee1967

Browse files
committed
chore: legitimize projections on tagged values
1 parent 9895e25 commit 5ee1967

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Lean/Compiler/IR/Checker.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ def checkExpr (ty : IRType) (e : Expr) : M Unit := do
159159
checkObjVar x
160160
| .proj i x =>
161161
let xType ← getType x;
162+
/-
163+
Projections are a valid operation on `tobject`. Thus they should also
164+
be a valid operation for both `object`, `tagged` and unboxed values
165+
as they are subtypes.
166+
-/
162167
match xType with
163168
| .object | .tobject =>
164169
checkObjType ty
@@ -167,6 +172,7 @@ def checkExpr (ty : IRType) (e : Expr) : M Unit := do
167172
checkEqTypes (tys[i]) ty
168173
else
169174
throwCheckerError "invalid proj index"
175+
| .tagged => pure ()
170176
| _ => throwCheckerError s!"unexpected IR type '{xType}'"
171177
| .uproj _ x =>
172178
checkObjVar x

0 commit comments

Comments
 (0)