lean4-htt/tests/lean/run/erased.lean
Cameron Zwarich c292ae2e0e
fix: don't create reduced arity LCNF decls with no params (#7086)
This PR makes the arity reduction pass in the new code generator match
the old one when it comes to the behavior of decls with no used
parameters. This is important, because otherwise we might create a
top-level decl with no params that contains unreachable code, which
would get evaluated unconditionally during initialization. This actually
happens when initializing Init.Core built with the new code generator.
2025-02-27 01:23:34 +00:00

29 lines
851 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.

import Lean
/-- `erased α` is the same as `α`, except that the elements
of `erased α` are erased in the VM in the same way as types
and proofs. This can be used to track data without storing it
literally. -/
def Erased (α : Sort u) : Sort max 1 u :=
Σ's : α → Prop, ∃ a, (fun b => a = b) = s
namespace Erased
/-- Erase a value. -/
@[inline]
def mk {α} (a : α) : Erased α :=
⟨fun b => a = b, a, rfl⟩
open Lean.Compiler
set_option pp.explicit true
set_option pp.funBinderTypes true
set_option pp.letVarTypes true
set_option trace.Compiler.result true
/--
info: [Compiler.result] size: 1
def Erased.mk (α : lcErased) (a : lcAny) : PSigma lcErased lcErased :=
let _x.1 : PSigma lcErased lcErased := PSigma.mk lcErased ◾ ◾ ◾;
return _x.1
-/
#guard_msgs in
run_meta Lean.Compiler.compile #[``Erased.mk]