Skip to content

Commit 2d2b0d6

Browse files
authored
flambda-backend: Fix toplevel printer for arrays of unboxed things (#2718)
* a fistful of tests printing arrays of unboxed nums Signed-off-by: David Vulakh <dvulakh@janestreet.com> * fix printer for arrays of unboxed things Signed-off-by: David Vulakh <dvulakh@janestreet.com> --------- Signed-off-by: David Vulakh <dvulakh@janestreet.com>
1 parent 41957b1 commit 2d2b0d6

File tree

3 files changed

+40
-18
lines changed

3 files changed

+40
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
val y : float array = [|1.; 2.; 3.; 4.|]
2+
val y : float# array = [|<abstr>; <abstr>; <abstr>; <abstr>|]
3+
val y : int32# array = <abstr array>
4+
val y : nativeint# array = <abstr array>
5+
val y : int64# array = <abstr array>
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(* TEST
2+
toplevel.opt;
3+
*)
4+
5+
let y = [| 1.0; 2.0; 3.0; 4.0 |];;
6+
7+
let y = [| #1.0; #2.0; #3.0; #4.0 |];;
8+
9+
let y = [| #1l; #2l; #3l; #4l |];;
10+
11+
let y = [| #1n; #2n; #3n; #4n |];;
12+
13+
let y = [| #1L; #2L; #3L; #4L |];;

toplevel/genprintval.ml

+21-18
Original file line numberDiff line numberDiff line change
@@ -620,25 +620,28 @@ module Make(O : OBJ)(EVP : EVALPATH with type valu = O.t) = struct
620620
tree_list start ty_list
621621

622622
and tree_of_generic_array am depth obj ty_arg =
623-
let oval elts = Oval_array (elts, am) in
624-
let length = O.size obj in
625-
if length > 0 then
626-
match check_depth depth obj ty with
627-
Some x -> x
628-
| None ->
629-
let rec tree_of_items tree_list i =
630-
if !printer_steps < 0 || depth < 0 then
631-
Oval_ellipsis :: tree_list
632-
else if i < length then
633-
let tree =
634-
nest tree_of_val (depth - 1) (O.field obj i) ty_arg
635-
in
636-
tree_of_items (tree :: tree_list) (i + 1)
637-
else tree_list
638-
in
639-
oval (List.rev (tree_of_items [] 0))
623+
if O.tag obj = Obj.custom_tag then
624+
Oval_stuff "<abstr array>"
640625
else
641-
oval []
626+
let oval elts = Oval_array (elts, am) in
627+
let length = O.size obj in
628+
if length > 0 then
629+
match check_depth depth obj ty with
630+
Some x -> x
631+
| None ->
632+
let rec tree_of_items tree_list i =
633+
if !printer_steps < 0 || depth < 0 then
634+
Oval_ellipsis :: tree_list
635+
else if i < length then
636+
let tree =
637+
nest tree_of_val (depth - 1) (O.field obj i) ty_arg
638+
in
639+
tree_of_items (tree :: tree_list) (i + 1)
640+
else tree_list
641+
in
642+
oval (List.rev (tree_of_items [] 0))
643+
else
644+
oval []
642645

643646
and tree_of_constr_with_args
644647
tree_of_cstr cstr_name inlined start depth obj ty_args unboxed =

0 commit comments

Comments
 (0)