Skip to content

Commit bdfad2f

Browse files
committed
fix: expose getCtorLayout from Lean to unbreak test
1 parent 7aec6c9 commit bdfad2f

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/Lean/Compiler/IR/CtorLayout.lean

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,15 @@ structure CtorLayout where
3535
numUSize : Nat
3636
scalarSize : Nat
3737

38-
@[extern "lean_ir_get_ctor_layout"]
3938
opaque getCtorLayout (env : @& Environment) (ctorName : @& Name) : Except String CtorLayout
4039

4140
end IR
41+
42+
-- Expose `getCtorLayout` in the `Lean` namespace to make it available for the benefit of
43+
-- the test `lean/ctor_layout.lean`
44+
-- Can be removed once we no longer have to limit the number of exported symbols and
45+
-- can use `Lean.IR` from the interpreter.
46+
@[extern "lean_ir_get_ctor_layout"]
47+
def getCtorLayout := IR.getCtorLayout
48+
4249
end Lean

tests/lean/ctor_layout.lean

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Lean.Compiler.IR
2+
3+
open Lean
4+
5+
unsafe def main : IO Unit :=
6+
withImportModules #[{module := `Lean.Compiler.IR.Basic}] {} 0 fun env => do
7+
let ctorLayout ← IO.ofExcept $ getCtorLayout env `Lean.IR.Expr.reuse;
8+
ctorLayout.fieldInfo.forM $ fun finfo => IO.println (format finfo);
9+
IO.println "---";
10+
let ctorLayout ← IO.ofExcept $ getCtorLayout env `Lean.EnvironmentHeader.mk;
11+
ctorLayout.fieldInfo.forM $ fun finfo => IO.println (format finfo);
12+
IO.println "---";
13+
let ctorLayout ← IO.ofExcept $ getCtorLayout env `Subtype.mk;
14+
ctorLayout.fieldInfo.forM $ fun finfo => IO.println (format finfo);
15+
pure ()
16+
17+
#eval main
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
obj@0
2+
obj@1
3+
scalar#1@0:u8
4+
obj@2
5+
---
6+
scalar#4@0:u32
7+
scalar#1@4:u8
8+
obj@0
9+
obj@1
10+
obj@2
11+
obj@3
12+
obj@4
13+
---
14+
obj@0
15+

0 commit comments

Comments
 (0)