Same code compiles with default options but fails the IR check with compiler.small=16
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- compilers
Direzione di ricerca
Start by reproducing the failure with the provided Program.lean and the -Dcompiler.small=16 option; compare it with the successful default run and with -Dcompiler.extract_closed=false. Then trace the compiler IR check error at makeShape through Lean's compiler and closed-term extraction paths. Done means the reproducer compiles with the higher threshold and the IR check accepts the resulting code.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Prerequisites
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”) - When reporting a perceived soundness bug: Does it affect
lake check --paranoid?
If in doubt, please reach out on [email protected] for responsible disclosure.
Description
On both Lean v4.36.0 and v4.38.0-nightly-2026-12-04, the example below compiles with the default options. Changing only compiler.small from 1 to 16 makes compilation fail with unexpected IR type 'u8'.
Context
I encountered this while compiling the same Lean file with different inlining thresholds.
Steps to Reproduce
-
Save the following as
Program.lean.inductive Shape where | leaf : Bool → Bool → Bool → Shape | node : Array Bool → Bool → Array Nat → Shape → Shape def makeShape (n : Nat) : Shape := if n == 100 then .node (((if true then ((true, n), true) else ((false, n), false)).1, if true then #[] else (let _ := n; #[])).2) ((id ((fun (_ : Nat) => (let _ := 7; #[] : Array Bool)) 31)).getD ((#[] : Array (Bool × Bool)).size + (#[] : Array Bool).size) ((let _ := false; false) == true)) (match (let s := Shape.leaf false true true; s) with | .leaf b _ _ => match Shape.leaf false b false with | .leaf .. | .node .. => #[] | .node _ _ xs _ => (fun (_ : Bool) => xs) false) (.node (let _ : Array Nat := #[]; #[].push false) (let b := false; b) (if false then #[] else #[].push 0) (.node (let _ := fun (_ : Bool × Nat) => (0 : Nat); #[]) (if true then true && true else false) (let _ := #[(#[] : Array Nat).size]; #[]) (.leaf (if false then !false else false) ((let _ : Array (Nat × Nat) := #[]; true), (31 : Nat)).1 ((fun (_ : Bool × Nat) => false) (false, 255))))) else if n == 0 then .leaf ((#[] : Array Bool).setIfInBounds 2 true |>.getD 63 (let _ := fun (_ : Bool × Nat) => (false, (#[] : Array Bool)).2; if true then true else !false)) (match (let _ : Array Nat := #[]; Shape.leaf false false (!true)) with | .leaf _ b _ => b && (n == 15) | .node _ b _ _ => (#[] : Array Bool).getD (#[] : Array (Array Bool)).size b) false else .node ((match Shape.leaf true (!false) false with | .leaf .. | .node .. => #[] : Array Bool).setIfInBounds 7 ((#[] : Array Bool).getD (#[] : Array Bool).size (!false))) (match Shape.leaf true false (let _ := false; false) with | .leaf .. => ((#[] : Array (Nat × Bool)).getD (#[] : Array (Bool × Bool)).size (15, true)).2 | .node xs b _ _ => (let _ := b; (true, xs)).1) ((let _ := 0; if false then #[] else #[]), (if false then false else false)).1 (.leaf true (let _ := ((0 : Nat), n); false) (false, (#[] : Array Nat)).1) -
Compile with the default options.
lean +leanprover/lean4:v4.36.0 Program.lean -
Compile the same file with a higher inlining threshold.
lean +leanprover/lean4:v4.36.0 -Dcompiler.small=16 Program.lean
Expected behavior: Both commands compile the file successfully.
Actual behavior: The default command exits with status 0. With compiler.small=16, Lean exits with status 1 and reports
Program.lean:5:4: error: failed to compile definition, compiler IR check failed at `makeShape`. Error: unexpected IR type 'u8'
Versions
Output of #eval Lean.versionString on Ubuntu 22.04.5 LTS (x86_64):
"4.36.0"
"4.38.0-nightly-2026-12-04"
Additional Information
On both versions, keeping compiler.small=16 and setting compiler.extract_closed=false makes the file compile successfully.
lean +leanprover/lean4:v4.36.0 -Dcompiler.small=16 -Dcompiler.extract_closed=false Program.lean
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
- Lingua principale
- Lean
- Stelle
- 10.5k
- Fork
- 1.2k
- Merge medio
- 19h 36m
- PR unite (30g)
- 323
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di leanprover/lean4
-
P-medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
leanprover/lean4#16958 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
leanprover/lean4#16897 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
leanprover/lean4#16892 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
leanprover/lean4#16886 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
leanprover/lean4#16820 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di leanprover/lean4
Issue simili
-
chat compiler P1
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
HerringtonDarkholme/hd-lang#2793 ·
I maintainer di solito rispondono entro 1 giorno
-
area-dart-model gardening
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 87/100
I maintainer di solito rispondono entro 1 giorno
-
`shift(x, y)` with a uint256 shift amount >= 2**255 shifts in the wrong directionForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 71/100
facebookexperimental/semcode#195 ·
I maintainer di solito rispondono entro 2 giorni