lean4-htt/tests/lean/run/never_extract.lean
Cameron Zwarich 81740da50a
fix: avoid caching uses of never_extract constants in toLCNF (#8956)
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.
2025-06-24 02:04:56 +00:00

34 lines
502 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)