Skip to content

Fix a bug in rec_check.ml for arrays of unboxed things #2390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions ocaml/testsuite/tests/typing-layouts-arrays/basics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,29 @@ Error: This expression has type ('a : float64)
But the layout of int32# must be a sublayout of float64, because
of the definition of arr at line 6, characters 12-16.
|}]

(*********************)
(* Test 7: rec check *)

(* See upstream PR #6939 *)

let _ =
let[@warning "-10"] rec x = [| x |]; #42.0 in
();;
[%%expect{|
Line 2, characters 30-44:
2 | let[@warning "-10"] rec x = [| x |]; #42.0 in
^^^^^^^^^^^^^^
Error: This kind of expression is not allowed as right-hand side of `let rec'
|}]

let _ =
let[@warning "-10"] rec x = [| x |]; #42L in
();;

[%%expect{|
Line 2, characters 30-43:
2 | let[@warning "-10"] rec x = [| x |]; #42L in
^^^^^^^^^^^^^
Error: This kind of expression is not allowed as right-hand side of `let rec'
|}]
2 changes: 1 addition & 1 deletion ocaml/typing/rec_check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ let array_mode exp elt_sort = match Typeopt.array_kind exp elt_sort with
(* non-generic, non-float arrays act as constructors *)
Guard
| Lambda.Punboxedfloatarray _ | Lambda.Punboxedintarray _ ->
Guard
Dereference

(* Expression judgment:
G |- e : m
Expand Down
Loading