fix: foldlM mismatch part 2 (#11779)

This PR fixes an oversight in the initial #11772 PR.

Closes #11778.
This commit is contained in:
Henrik Böving 2025-12-23 11:29:20 +01:00 committed by GitHub
parent a471f005d6
commit 4d2647f9c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 3 deletions

View file

@ -589,8 +589,10 @@ unsafe def foldlMUnsafe {α : Type u} {β : Type v} {m : Type v → Type w} [Mon
if start < stop then
if stop ≤ as.size then
fold (USize.ofNat start) (USize.ofNat stop) init
else
else if start < as.size then
fold (USize.ofNat start) (USize.ofNat as.size) init
else
pure init
else
pure init

View file

@ -269,8 +269,10 @@ unsafe def foldlMUnsafe {β : Type v} {m : Type v → Type w} [Monad m] (f : β
if start < stop then
if stop ≤ as.size then
fold (USize.ofNat start) (USize.ofNat stop) init
else
else if start < as.size then
fold (USize.ofNat start) (USize.ofNat as.size) init
else
pure init
else
pure init

View file

@ -144,8 +144,10 @@ unsafe def foldlMUnsafe {β : Type v} {m : Type v → Type w} [Monad m] (f : β
if start < stop then
if stop ≤ as.size then
fold (USize.ofNat start) (USize.ofNat stop) init
else
else if start < as.size then
fold (USize.ofNat start) (USize.ofNat as.size) init
else
pure init
else
pure init

11
tests/lean/run/11778.lean Normal file
View file

@ -0,0 +1,11 @@
/-- info: 0 -/
#guard_msgs in
#eval Array.foldl (·+·) 0 #[1,2,3] (start := 5) (stop := 10)
/-- info: 0 -/
#guard_msgs in
#eval ByteArray.foldl (·+·) 0 ⟨#[1,2,3]⟩ (start := 5) (stop := 10)
/-- info: 0.000000 -/
#guard_msgs in
#eval FloatArray.foldl (·+·) 0 ⟨#[1,2,3]⟩ (start := 5) (stop := 10)