lean4-htt/tests/elab/extractClosed.lean
Henrik Böving b1db0d2798
perf: non quadratic closed term initialization for closed array literals (#12715)
This PR ensures the compiler extracts `Array`/`ByteArray`/`FloatArray`
literals as one big closed term to avoid quadratic overhead at closed
term initialization time.
2026-02-27 08:37:12 +00:00

27 lines
701 B
Text

/--
trace: [Compiler.IR] [result]
def f._closed_0 : obj :=
let x_1 : tagged := 1;
let x_2 : obj := Array.mkEmpty ◾ x_1;
let x_3 : obj := Array.push ◾ x_2 x_1;
ret x_3
def f : obj :=
let x_1 : obj := f._closed_0;
ret x_1
-/
#guard_msgs in
set_option trace.compiler.ir.result true in
def f : Array Nat := #[1]
/--
trace: [Compiler.IR] [result]
def g (x_1 : tobj) : obj :=
let x_2 : tagged := 1;
let x_3 : obj := Array.mkEmpty ◾ x_2;
let x_4 : obj := Array.push ◾ x_3 x_1;
ret x_4
-/
#guard_msgs in
set_option trace.compiler.ir.result true in
set_option compiler.extract_closed false in
def g (a : Nat) : Array Nat := #[a]