Skip to content

Commit 5e165e3

Browse files
authored
fix: better types when creating boxed decls (#11445)
This PR slightly improves the types involved in creating boxed declarations. Previously the type of the vdecl used for the return was always `tobj` when returning a boxed scalar. This is not the most precise annotation we can give.
1 parent 429734c commit 5e165e3

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/Lean/Compiler/IR/Boxing.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def mkBoxedVersionAux (decl : Decl) : N Decl := do
5353
pure <| reshape newVDecls (.ret (.var r))
5454
else
5555
let newR ← N.mkFresh
56-
let newVDecls := newVDecls.push (.vdecl newR .tobject (.box decl.resultType r) default)
56+
let newVDecls := newVDecls.push (.vdecl newR decl.resultType.boxed (.box decl.resultType r) default)
5757
pure <| reshape newVDecls (.ret (.var newR))
5858
return Decl.fdecl (mkBoxedName decl.name) qs decl.resultType.boxed body decl.getInfo
5959

tests/lean/4240.lean.expected.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
def isSomeWithInstanceNat._boxed (x_1 : obj) : tagged :=
1717
let x_2 : u8 := isSomeWithInstanceNat x_1;
1818
dec x_1;
19-
let x_3 : tobj := box x_2;
19+
let x_3 : tagged := box x_2;
2020
ret x_3
2121
def MyOption.isSomeWithInstance._at_.isSomeWithInstanceNat.spec_0._boxed (x_1 : tobj) : tagged :=
2222
let x_2 : u8 := MyOption.isSomeWithInstance._at_.isSomeWithInstanceNat.spec_0 x_1;
2323
dec x_1;
24-
let x_3 : tobj := box x_2;
24+
let x_3 : tagged := box x_2;
2525
ret x_3

tests/lean/computedFieldsCode.lean.expected.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@
287287
def g._boxed (x_1 : tobj) : tagged :=
288288
let x_2 : u8 := g x_1;
289289
dec x_1;
290-
let x_3 : tobj := box x_2;
290+
let x_3 : tagged := box x_2;
291291
ret x_3
292292
[Compiler.IR] [result]
293293
def hash' (x_1 : @& tobj) : tobj :=

tests/lean/run/10934.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ trace: [Compiler.IR] [result]
1717
let x_3 : u8 := unbox x_1;
1818
let x_4 : u8 := unbox x_2;
1919
let x_5 : u8 := _example x_3 x_4;
20-
let x_6 : tobj := box x_5;
20+
let x_6 : tagged := box x_5;
2121
ret x_6
2222
-/
2323
#guard_msgs in
@@ -36,7 +36,7 @@ trace: [Compiler.IR] [result]
3636
let x_3 : u8 := unbox x_1;
3737
let x_4 : u8 := unbox x_2;
3838
let x_5 : u8 := _example x_3 x_4;
39-
let x_6 : tobj := box x_5;
39+
let x_6 : tagged := box x_5;
4040
ret x_6
4141
-/
4242
#guard_msgs in
@@ -54,7 +54,7 @@ trace: [Compiler.IR] [result]
5454
let x_3 : u8 := unbox x_1;
5555
let x_4 : u8 := unbox x_2;
5656
let x_5 : u8 := _example x_3 x_4;
57-
let x_6 : tobj := box x_5;
57+
let x_6 : tagged := box x_5;
5858
ret x_6
5959
-/
6060
#guard_msgs in
@@ -67,7 +67,7 @@ trace: [Compiler.IR] [result]
6767
def _example._boxed (x_1 : tagged) : tagged :=
6868
let x_2 : u8 := unbox x_1;
6969
let x_3 : u8 := _example x_2;
70-
let x_4 : tobj := box x_3;
70+
let x_4 : tagged := box x_3;
7171
ret x_4
7272
-/
7373
#guard_msgs in

tests/lean/sint_basic.lean.expected.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ true
7878
def _private.lean.sint_basic.0.myId8._boxed (x_1 : tagged) : tagged :=
7979
let x_2 : u8 := unbox x_1;
8080
let x_3 : u8 := _private.lean.sint_basic.0.myId8 x_2;
81-
let x_4 : tobj := box x_3;
81+
let x_4 : tagged := box x_3;
8282
ret x_4
8383
Int16 : Type
8484
20
@@ -160,7 +160,7 @@ true
160160
def _private.lean.sint_basic.0.myId16._boxed (x_1 : tagged) : tagged :=
161161
let x_2 : u16 := unbox x_1;
162162
let x_3 : u16 := _private.lean.sint_basic.0.myId16 x_2;
163-
let x_4 : tobj := box x_3;
163+
let x_4 : tagged := box x_3;
164164
ret x_4
165165
Int32 : Type
166166
20

0 commit comments

Comments
 (0)