File tree Expand file tree Collapse file tree 2 files changed +66
-1
lines changed
Expand file tree Collapse file tree 2 files changed +66
-1
lines changed Original file line number Diff line number Diff line change @@ -166,8 +166,12 @@ where
166166 | .proj ``Subtype 0 (.const ``IO.RealWorld.nonemptyType []) =>
167167 return mkConst ``lcRealWorld
168168 | _ => return mkConst ``lcAny
169+
169170 whnfEta (type : Expr) : MetaM Expr := do
170- let type ← whnf type
171+ -- We increase transparency here to unfold type aliases of functions that are declared as
172+ -- `irreducible`, such that they end up being represented as C functions.
173+ let type ← withTransparency .all do
174+ whnf type
171175 let type' := type.eta
172176 if type' != type then
173177 whnfEta type'
Original file line number Diff line number Diff line change 1+ /-!
2+ This test ensures that the code generator sees the same type representation regardless of
3+ transparency setting in the elaborator. If this test ever breaks you should ensure that the IR
4+ between A and B is in sync.
5+ -/
6+
7+ namespace A
8+
9+ @[irreducible] def Function (α β : Type ) := α → β
10+
11+ namespace Function
12+
13+ attribute [local semireducible] Function
14+
15+ @[inline]
16+ def id : Function α α := fun x => x
17+
18+ end Function
19+
20+ /--
21+ trace: [ Compiler.IR ] [ result ]
22+ def A.foo (x_1 : @& tobj) : tobj :=
23+ inc x_1;
24+ ret x_1
25+ def A.foo._boxed (x_1 : tobj) : tobj :=
26+ let x_2 : tobj := A.foo x_1;
27+ dec x_1;
28+ ret x_2
29+ -/
30+ #guard_msgs in
31+ set_option trace.compiler.ir.result true in
32+ def foo : Function Nat Nat := Function.id
33+
34+ end A
35+
36+ namespace B
37+
38+ def Function (α β : Type ) := α → β
39+
40+ namespace Function
41+
42+ @[inline]
43+ def id : Function α α := fun x => x
44+
45+ end Function
46+
47+ /--
48+ trace: [ Compiler.IR ] [ result ]
49+ def B.foo (x_1 : @& tobj) : tobj :=
50+ inc x_1;
51+ ret x_1
52+ def B.foo._boxed (x_1 : tobj) : tobj :=
53+ let x_2 : tobj := B.foo x_1;
54+ dec x_1;
55+ ret x_2
56+ -/
57+ #guard_msgs in
58+ set_option trace.compiler.ir.result true in
59+ def foo : Function Nat Nat := Function.id
60+
61+ end B
You can’t perform that action at this time.
0 commit comments