Skip to content

Commit 62e46fb

Browse files
committed
Fix extraction of primitive array literal
Fix #22365
1 parent 96672d4 commit 62e46fb

6 files changed

Lines changed: 19 additions & 7 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- **Fixed:**
2+
extraction of primitive array literals
3+
(`#22457 <https://github.com/rocq-prover/rocq/pull/22457>`_,
4+
fixes `#22365 <https://github.com/rocq-prover/rocq/issues/22365>`_,
5+
by Gaëtan Gilbert).

plugins/extraction/common.ml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ let pp_boxed_tuple f = function
6363
| [x] -> f x
6464
| l -> pp_par true (hov 0 (prlist_with_sep (fun () -> str "," ++ spc ()) f l))
6565

66-
let pp_array f = function
67-
| [] -> mt ()
68-
| [x] -> f x
69-
| l -> pp_par true (prlist_with_sep (fun () -> str ";" ++ spc ()) f l)
70-
7166
(** By default, in module Format, you can do horizontal placing of blocks
7267
even if they include newlines, as long as the number of chars in the
7368
blocks is less that a line length. To avoid this awkward situation,

plugins/extraction/common.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ val pp_apply2 : Pp.t -> bool -> Pp.t list -> Pp.t
3030

3131
val pp_tuple_light : (bool -> 'a -> Pp.t) -> 'a list -> Pp.t
3232
val pp_tuple : ('a -> Pp.t) -> 'a list -> Pp.t
33-
val pp_array : ('a -> Pp.t) -> 'a list -> Pp.t
3433
val pp_boxed_tuple : ('a -> Pp.t) -> 'a list -> Pp.t
3534

3635
val pr_binding : Id.t list -> Pp.t

plugins/extraction/ocaml.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ let rec pp_expr table par env args =
326326
str "(" ++ str (Pstring.compile s) ++ str ")"
327327
| MLparray(t,def) ->
328328
assert (args=[]);
329-
let tuple = pp_array (pp_expr table true env []) (Array.to_list t) in
329+
let tuple = prlist_with_sep pr_semicolon (pp_expr table true env []) (Array.to_list t) in
330330
let def = pp_expr table true env [] def in
331331
str "(ExtrNative.of_array [|" ++ tuple ++ str "|]" ++ spc () ++ def ++ str")"
332332

test-suite/output/bug_22365.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
File "./output/bug_22365.v", line 5, characters 0-17:
2+
Warning: The following axiom must be realized in the extracted code:
3+
array.
4+
[extraction-axiom-to-realize,extraction,default]
5+
(** val a3lit : nat array **)
6+
7+
let a3lit =
8+
(ExtrNative.of_array [|O; (S O); (S (S O))|] (S (S (S (S O)))))

test-suite/output/bug_22365.v

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
From Corelib Require Import Array.PrimArray Numbers.Cyclic.Int63.PrimInt63 extraction.Extraction.
2+
3+
Definition a3lit : PrimArray.array nat := [|0; 1; 2 | 4|].
4+
5+
Extraction a3lit.

0 commit comments

Comments
 (0)