This PR changes `toLCNF` to stop caching translations of expressions upon seeing an expression marked `never_extract`. This is more coarse-grained than it needs to be, but it is difficult to do any better, as the new compiler's `Expr` cache is based on structural identity (rather than the pointer identity of the old compiler). The newly added `tests/compiler/never_extract.lean` is also converted into a `run` tests, because during development I found the order of the output to `stderr` to be a bit finicky. The reason for making it a `compiler` test in the first place is that closed term decls work slightly differently between native code and the interpreter, and it would be good to test both, but we already have separate tests for `never_extract` and closed term extraction. Fixes #8944.
34 lines
502 B
Text
34 lines
502 B
Text
def test1 (a : Nat) : Nat :=
|
||
let f a :=
|
||
dbg_trace s!"{a}"
|
||
a
|
||
let g a :=
|
||
dbg_trace s!"{a + 0}"
|
||
a
|
||
(f a) + (g a)
|
||
|
||
/--
|
||
info: 1
|
||
1
|
||
---
|
||
info: 2
|
||
-/
|
||
#guard_msgs in
|
||
#eval test1 1
|
||
|
||
structure Twice (α : Type u) where
|
||
first : α
|
||
second : α
|
||
first_eq_second : first = second
|
||
|
||
instance : Coe α (Twice α) where
|
||
coe x := ⟨x, x, rfl⟩
|
||
|
||
/--
|
||
info: hello
|
||
hello
|
||
---
|
||
info: { first := 5, second := 5, first_eq_second := _ }
|
||
-/
|
||
#guard_msgs in
|
||
#eval ((dbg_trace "hello"; 5 : Nat) : Twice Nat)
|