Same code compiles with default options but fails the IR check with compiler.small=16
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- compilers
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Lean
- Stars
- 10.5k
- Forks
- 1.2k
- Avg merge
- 19h 36m
- Merged PRs (30d)
- 323
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from leanprover/lean4
-
P-medium
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
leanprover/lean4#16958 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
leanprover/lean4#16897 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
leanprover/lean4#16892 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
leanprover/lean4#16886 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 78/100
leanprover/lean4#16820 ·
Maintainers usually reply within 1 day
All issues in leanprover/lean4
Similar issues
-
area-dart-model gardening
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
Maintainers usually reply within 1 day
-
`shift(x, y)` with a uint256 shift amount >= 2**255 shifts in the wrong directionPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 71/100
facebookexperimental/semcode#195 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
stjude-rust-labs/sprocket#1476 · 3 comments ·
Maintainers usually reply within 1 day