Skip to content

Commit 24bf5b3

Browse files
authored
flambda-backend: Fix a bug in rec_check.ml for arrays of unboxed things (#2390)
Fix a bug in rec_check.ml for arrays of unboxed things
1 parent f025246 commit 24bf5b3

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

testsuite/tests/typing-layouts-arrays/basics.ml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,29 @@ Error: This expression has type ('a : float64)
254254
But the layout of int32# must be a sublayout of float64, because
255255
of the definition of arr at line 6, characters 12-16.
256256
|}]
257+
258+
(*********************)
259+
(* Test 7: rec check *)
260+
261+
(* See upstream PR #6939 *)
262+
263+
let _ =
264+
let[@warning "-10"] rec x = [| x |]; #42.0 in
265+
();;
266+
[%%expect{|
267+
Line 2, characters 30-44:
268+
2 | let[@warning "-10"] rec x = [| x |]; #42.0 in
269+
^^^^^^^^^^^^^^
270+
Error: This kind of expression is not allowed as right-hand side of `let rec'
271+
|}]
272+
273+
let _ =
274+
let[@warning "-10"] rec x = [| x |]; #42L in
275+
();;
276+
277+
[%%expect{|
278+
Line 2, characters 30-43:
279+
2 | let[@warning "-10"] rec x = [| x |]; #42L in
280+
^^^^^^^^^^^^^
281+
Error: This kind of expression is not allowed as right-hand side of `let rec'
282+
|}]

typing/rec_check.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ let array_mode exp elt_sort = match Typeopt.array_kind exp elt_sort with
528528
(* non-generic, non-float arrays act as constructors *)
529529
Guard
530530
| Lambda.Punboxedfloatarray _ | Lambda.Punboxedintarray _ ->
531-
Guard
531+
Dereference
532532

533533
(* Expression judgment:
534534
G |- e : m

0 commit comments

Comments
 (0)