Skip to content

Commit 92d3d6b

Browse files
committed
poke
1 parent d0f3098 commit 92d3d6b

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/Init/GetElem.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ instance : LawfulGetElem (Array α) Nat α fun xs i => i < xs.size where
410410
a.get!Internal i = a[i]! := by
411411
simp only [get!Internal, getD, getInternal_eq_getElem, getElem!_def]
412412
split <;> simp_all [getElem?_pos, getElem?_neg]
413+
simp [default]
413414

414415
end Array
415416

src/Init/Prelude.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3252,16 +3252,16 @@ Version of `Array.get!Internal` that does not increment the reference count of i
32523252
This is only intended for direct use by the compiler.
32533253
-/
32543254
@[extern "lean_array_get_borrowed"]
3255-
unsafe opaque Array.get!InternalBorrowed {α : Type u} [Inhabited α] (a : @& Array α) (i : @& Nat) : α
3255+
unsafe opaque Array.get!InternalBorrowed {α : Type u} [inst : Inhabited (Unit → α)] (a : @& Array α) (i : @& Nat) : α := inst.default ()
32563256

32573257
/--
32583258
Use the indexing notation `a[i]!` instead.
32593259
32603260
Access an element from an array, or panic if the index is out of bounds.
32613261
-/
32623262
@[extern "lean_array_get"]
3263-
def Array.get!Internal {α : Type u} [Inhabited α] (a : @& Array α) (i : @& Nat) : α :=
3264-
Array.getD a i default
3263+
def Array.get!Internal {α : Type u} [inst : Inhabited (Unit → α)] (a : @& Array α) (i : @& Nat) : α :=
3264+
Array.getD a i (inst.default ())
32653265

32663266
/--
32673267
Adds an element to the end of an array. The resulting array's size is one greater than the input

src/Lean/Compiler/LCNF/ExtractClosed.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ partial def visitCode (code : Code) : M Code := do
127127
match code with
128128
| .let decl k =>
129129
let should ← shouldExtractLetValue true decl.value
130-
trace[Meta.debug] m!"Should extract: {← ppLetValue decl.value}? {should}"
131130
if should then
132131
let ⟨_, decls⟩ ← extractLetValue decl.value |>.run {}
133132
let decls := decls.reverse.push (.let decl)

src/include/lean/lean.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ static inline lean_object * lean_array_get(lean_obj_arg def_val, b_lean_obj_arg
844844
i > LEAN_MAX_SMALL_NAT == MAX_UNSIGNED >> 1
845845
but each array entry is 8 bytes in 64-bit machines and 4 in 32-bit ones.
846846
In both cases, we would be out-of-memory. */
847-
return lean_array_get_panic(def_val);
847+
return lean_array_get_panic(lean_apply_1(def_val, lean_box(0)));
848848
}
849849

850850
static inline lean_object * lean_array_get_borrowed(lean_obj_arg def_val, b_lean_obj_arg a, b_lean_obj_arg i) {
@@ -859,7 +859,7 @@ static inline lean_object * lean_array_get_borrowed(lean_obj_arg def_val, b_lean
859859
i > LEAN_MAX_SMALL_NAT == MAX_UNSIGNED >> 1
860860
but each array entry is 8 bytes in 64-bit machines and 4 in 32-bit ones.
861861
In both cases, we would be out-of-memory. */
862-
return lean_array_get_panic(def_val);
862+
return lean_array_get_panic(lean_apply_1(def_val, lean_box(0)));
863863
}
864864

865865
LEAN_EXPORT lean_obj_res lean_copy_expand_array(lean_obj_arg a, bool expand);

0 commit comments

Comments
 (0)