Skip to content

Commit f9586f1

Browse files
Copilotnomeata
andcommitted
fix: mark ByteArray.Iterator Inhabited instance as noncomputable
The Iterator structure has a custom SizeOf instance that depends on runtime array size, making the Inhabited instance noncomputable. This change explicitly marks it as such and adds a comment explaining why. Related: https://leanprover.zulipchat.com/#narrow/channel/113489-new-members/topic/Compiler.20error.20with.20sizeOf/with/561532734 Co-authored-by: nomeata <[email protected]>
1 parent cba30de commit f9586f1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Init/Data/ByteArray/Basic.lean

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,12 @@ structure Iterator where
338338
`Iterator.next` when `Iterator.atEnd` is true. If the position is not valid, then the
339339
current byte is `(default : UInt8)`. -/
340340
idx : Nat
341-
deriving Inhabited
342341
set_option doc.verso true
343342

343+
/-- Noncomputable because it depends on the custom `SizeOf` instance which uses runtime array size. -/
344+
noncomputable instance : Inhabited Iterator where
345+
default := ⟨default, default⟩
346+
344347
/-- Creates an iterator at the beginning of an array. -/
345348
def mkIterator (arr : ByteArray) : Iterator :=
346349
⟨arr, 0

0 commit comments

Comments
 (0)