Skip to content

Commit

Permalink
Move or_null back to beta (#3625)
Browse files Browse the repository at this point in the history
* `or_null` is beta

* fix existing or-null tests

* `or_null` is not stable

* format

* fix exports

* accept test_iarray_typeopt

* more tests

* beta universe instead of alpha

---------

Co-authored-by: Diana Kalinichenko <[email protected]>
  • Loading branch information
dkalinichenko-js and d-kalinichenko authored Feb 26, 2025
1 parent 4c486f4 commit bff2e7d
Show file tree
Hide file tree
Showing 23 changed files with 127 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@

open Stdlib_beta

(* Test that [Or_null] is exported. *)

let () =
match Or_null.null with
| Null -> ()
| This _ -> assert false
;;
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,3 @@ let () =
assert (Float32_u.to_int one = 1)
;;

(* Test that [Or_null] is exported. *)

let () =
match Or_null.null with
| Null -> ()
| This _ -> assert false
;;
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions otherlibs/stdlib_beta/stdlib_beta.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module Int8 = Int8
module Int16 = Int16
module Int_wrapper = Int_wrapper
module Or_null = Or_null
1 change: 1 addition & 0 deletions otherlibs/stdlib_beta/stdlib_beta.mli
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module Int8 = Int8
module Int16 = Int16
module Int_wrapper = Int_wrapper
module Or_null = Or_null
1 change: 0 additions & 1 deletion otherlibs/stdlib_stable/amd64/stdlib_stable.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ module Iarray = Iarray
module IarrayLabels = IarrayLabels
module Float32 = Float32
module Float32_u = Float32_u
module Or_null = Or_null
1 change: 0 additions & 1 deletion otherlibs/stdlib_stable/amd64/stdlib_stable.mli
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ module Iarray = Iarray
module IarrayLabels = IarrayLabels
module Float32 = Float32
module Float32_u = Float32_u
module Or_null = Or_null
1 change: 0 additions & 1 deletion otherlibs/stdlib_stable/generic/stdlib_stable.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
module Iarray = Iarray
module IarrayLabels = IarrayLabels
module Or_null = Or_null
1 change: 0 additions & 1 deletion otherlibs/stdlib_stable/generic/stdlib_stable.mli
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
module Iarray = Iarray
module IarrayLabels = IarrayLabels
module Or_null = Or_null
112 changes: 56 additions & 56 deletions testsuite/tests/lib-array/test_iarray_typeopt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,29 @@ let _ = [| [: :] |];;

let arr = [: 1; 2; 3 :];;
[%%expect {|
(let (arr/379 = (makearray_imm[int] 1 2 3))
(apply (field_imm 1 (global Toploop!)) "arr" arr/379))
(let (arr/377 = (makearray_imm[int] 1 2 3))
(apply (field_imm 1 (global Toploop!)) "arr" arr/377))
val arr : int iarray = [:1; 2; 3:]
|}];;

let _ = arr.:(1);;
[%%expect {|
(let (arr/379 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.get[int indexed by int] arr/379 1))
(let (arr/377 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.get[int indexed by int] arr/377 1))
- : int = 2
|}]

let _ = get arr 1;;
[%%expect {|
(let (arr/379 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.get[int indexed by int] arr/379 1))
(let (arr/377 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.get[int indexed by int] arr/377 1))
- : int = 2
|}]

let _ = unsafe_get arr 1;;
[%%expect {|
(let (arr/379 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.unsafe_get[int indexed by int] arr/379 1))
(let (arr/377 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.unsafe_get[int indexed by int] arr/377 1))
- : int = 2
|}]

Expand All @@ -71,94 +71,94 @@ let arr : int alias = [: 1; 2; 3 :];;
[%%expect {|
0
type 'a alias = 'a iarray
(let (arr/381 = (makearray_imm[int] 1 2 3))
(apply (field_imm 1 (global Toploop!)) "arr" arr/381))
(let (arr/379 = (makearray_imm[int] 1 2 3))
(apply (field_imm 1 (global Toploop!)) "arr" arr/379))
val arr : int alias = [:1; 2; 3:]
|}];;

let _ = arr.:(1);;
[%%expect {|
(let (arr/381 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.get[int indexed by int] arr/381 1))
(let (arr/379 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.get[int indexed by int] arr/379 1))
- : int = 2
|}]

let _ = get arr 1;;
[%%expect {|
(let (arr/381 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.get[int indexed by int] arr/381 1))
(let (arr/379 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.get[int indexed by int] arr/379 1))
- : int = 2
|}]

let _ = unsafe_get arr 1;;
[%%expect {|
(let (arr/381 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.unsafe_get[int indexed by int] arr/381 1))
(let (arr/379 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.unsafe_get[int indexed by int] arr/379 1))
- : int = 2
|}]

let mut_arr = [| 1; 2; 3 |];;
let arr = of_array mut_arr;;
[%%expect {|
(let (mut_arr/382 =[intarray] (makearray[int] 1 2 3))
(apply (field_imm 1 (global Toploop!)) "mut_arr" mut_arr/382))
(let (mut_arr/380 =[intarray] (makearray[int] 1 2 3))
(apply (field_imm 1 (global Toploop!)) "mut_arr" mut_arr/380))
val mut_arr : int array = [|1; 2; 3|]
(let
(mut_arr/382 = (apply (field_imm 0 (global Toploop!)) "mut_arr")
arr/383 =
(apply (field_imm 13 (global Stdlib_stable__Iarray!)) mut_arr/382))
(apply (field_imm 1 (global Toploop!)) "arr" arr/383))
(mut_arr/380 = (apply (field_imm 0 (global Toploop!)) "mut_arr")
arr/381 =
(apply (field_imm 13 (global Stdlib_stable__Iarray!)) mut_arr/380))
(apply (field_imm 1 (global Toploop!)) "arr" arr/381))
val arr : int iarray = [:1; 2; 3:]
|}];;

let _ = arr.:(1);;
[%%expect {|
(let (arr/383 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.get[int indexed by int] arr/383 1))
(let (arr/381 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.get[int indexed by int] arr/381 1))
- : int = 2
|}]

let _ = get arr 1;;
[%%expect {|
(let (arr/383 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.get[int indexed by int] arr/383 1))
(let (arr/381 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.get[int indexed by int] arr/381 1))
- : int = 2
|}]

let _ = unsafe_get arr 1;;
[%%expect {|
(let (arr/383 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.unsafe_get[int indexed by int] arr/383 1))
(let (arr/381 = (apply (field_imm 0 (global Toploop!)) "arr"))
(iarray.unsafe_get[int indexed by int] arr/381 1))
- : int = 2
|}]

(* And check that arrays are still mutable loads (array.get) *)

let mut_arr = [| 1; 2; 3 |];;
[%%expect {|
(let (mut_arr/384 =[intarray] (makearray[int] 1 2 3))
(apply (field_imm 1 (global Toploop!)) "mut_arr" mut_arr/384))
(let (mut_arr/382 =[intarray] (makearray[int] 1 2 3))
(apply (field_imm 1 (global Toploop!)) "mut_arr" mut_arr/382))
val mut_arr : int array = [|1; 2; 3|]
|}]

let _ = mut_arr.(1);;
[%%expect {|
(let (mut_arr/384 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.get[int indexed by int] mut_arr/384 1))
(let (mut_arr/382 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.get[int indexed by int] mut_arr/382 1))
- : int = 2
|}]

let _ = Array.get mut_arr 1;;
[%%expect {|
(let (mut_arr/384 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.get[int indexed by int] mut_arr/384 1))
(let (mut_arr/382 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.get[int indexed by int] mut_arr/382 1))
- : int = 2
|}]

let _ = Array.unsafe_get mut_arr 1;;
[%%expect {|
(let (mut_arr/384 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.unsafe_get[int indexed by int] mut_arr/384 1))
(let (mut_arr/382 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.unsafe_get[int indexed by int] mut_arr/382 1))
- : int = 2
|}]

Expand All @@ -167,63 +167,63 @@ let mut_arr : int alias = [| 1; 2; 3 |];;
[%%expect {|
0
type 'a alias = 'a array
(let (mut_arr/436 =[intarray] (makearray[int] 1 2 3))
(apply (field_imm 1 (global Toploop!)) "mut_arr" mut_arr/436))
(let (mut_arr/434 =[intarray] (makearray[int] 1 2 3))
(apply (field_imm 1 (global Toploop!)) "mut_arr" mut_arr/434))
val mut_arr : int alias = [|1; 2; 3|]
|}];;

let _ = mut_arr.(1);;
[%%expect {|
(let (mut_arr/436 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.get[int indexed by int] mut_arr/436 1))
(let (mut_arr/434 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.get[int indexed by int] mut_arr/434 1))
- : int = 2
|}]

let _ = Array.get mut_arr 1;;
[%%expect {|
(let (mut_arr/436 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.get[int indexed by int] mut_arr/436 1))
(let (mut_arr/434 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.get[int indexed by int] mut_arr/434 1))
- : int = 2
|}]

let _ = Array.unsafe_get mut_arr 1;;
[%%expect {|
(let (mut_arr/436 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.unsafe_get[int indexed by int] mut_arr/436 1))
(let (mut_arr/434 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.unsafe_get[int indexed by int] mut_arr/434 1))
- : int = 2
|}]

let arr = [: 1; 2; 3 :];;
let mut_arr = to_array arr;;
[%%expect {|
(let (arr/437 = (makearray_imm[int] 1 2 3))
(apply (field_imm 1 (global Toploop!)) "arr" arr/437))
(let (arr/435 = (makearray_imm[int] 1 2 3))
(apply (field_imm 1 (global Toploop!)) "arr" arr/435))
val arr : int iarray = [:1; 2; 3:]
(let
(arr/437 = (apply (field_imm 0 (global Toploop!)) "arr")
mut_arr/438 =[intarray]
(apply (field_imm 12 (global Stdlib_stable__Iarray!)) arr/437))
(apply (field_imm 1 (global Toploop!)) "mut_arr" mut_arr/438))
(arr/435 = (apply (field_imm 0 (global Toploop!)) "arr")
mut_arr/436 =[intarray]
(apply (field_imm 12 (global Stdlib_stable__Iarray!)) arr/435))
(apply (field_imm 1 (global Toploop!)) "mut_arr" mut_arr/436))
val mut_arr : int array = [|1; 2; 3|]
|}];;

let _ = mut_arr.(1);;
[%%expect {|
(let (mut_arr/438 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.get[int indexed by int] mut_arr/438 1))
(let (mut_arr/436 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.get[int indexed by int] mut_arr/436 1))
- : int = 2
|}]

let _ = Array.get mut_arr 1;;
[%%expect {|
(let (mut_arr/438 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.get[int indexed by int] mut_arr/438 1))
(let (mut_arr/436 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.get[int indexed by int] mut_arr/436 1))
- : int = 2
|}]

let _ = Array.unsafe_get mut_arr 1;;
[%%expect {|
(let (mut_arr/438 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.unsafe_get[int indexed by int] mut_arr/438 1))
(let (mut_arr/436 = (apply (field_imm 0 (global Toploop!)) "mut_arr"))
(array.unsafe_get[int indexed by int] mut_arr/436 1))
- : int = 2
|}]
1 change: 1 addition & 0 deletions testsuite/tests/typing-layouts-or-null/basics.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(* TEST
flags = "-extension-universe beta";
expect;
*)

Expand Down
1 change: 1 addition & 0 deletions testsuite/tests/typing-layouts-or-null/containers.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(* TEST
flags = "-extension-universe beta";
expect;
*)

Expand Down
1 change: 1 addition & 0 deletions testsuite/tests/typing-layouts-or-null/probe.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(* TEST
flags = "-extension-universe beta";
arch_amd64;
not-macos;
native;
Expand Down
1 change: 1 addition & 0 deletions testsuite/tests/typing-layouts-or-null/reexport.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(* TEST
flags = "-extension-universe beta";
expect;
*)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
File "reexport_attr_unused.ml", line 8, characters 5-21:
8 | let[@or_null_reexport] x = 5
File "reexport_attr_unused.ml", line 9, characters 5-21:
9 | let[@or_null_reexport] x = 5
^^^^^^^^^^^^^^^^
Warning 53 [misplaced-attribute]: the "or_null_reexport" attribute cannot appear in this context

File "reexport_attr_unused.ml", line 11, characters 6-22:
11 | [@@@or_null_reexport]
File "reexport_attr_unused.ml", line 12, characters 6-22:
12 | [@@@or_null_reexport]
^^^^^^^^^^^^^^^^
Warning 53 [misplaced-attribute]: the "or_null_reexport" attribute cannot appear in this context
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(* TEST
flags = "-extension-universe beta";
ocamlc_byte_exit_status = "0";
setup-ocamlc.byte-build-env;
ocamlc.byte;
Expand Down
1 change: 1 addition & 0 deletions testsuite/tests/typing-layouts-or-null/runtime.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(* TEST
flags = "-extension-universe beta";
*)

let x = Null
Expand Down
45 changes: 45 additions & 0 deletions testsuite/tests/typing-layouts-or-null/stable.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
(* TEST
flags = "-extension-universe stable";
expect;
*)

(* CR dkalinichenko: [or_null] is not available in [stable]. *)
let x : int or_null = This 3

[%%expect{|
Line 1, characters 12-19:
1 | let x : int or_null = This 3
^^^^^^^
Error: Unbound type constructor "or_null"
|}]

(* CR dkalinichenko: [Null] and [This] are not available in [stable]. *)

let y = Null

[%%expect{|
Line 1, characters 8-12:
1 | let y = Null
^^^^
Error: Unbound constructor "Null"
|}]

let z = This 5

[%%expect{|
Line 1, characters 8-12:
1 | let z = This 5
^^^^
Error: Unbound constructor "This"
|}]

(* CR dkalinichenko: [or_null_reexport] is not available in [stable]. *)

type 'a my_or_null : value_or_null = 'a or_null [@@or_null_reexport]
[%%expect{|
Line 1, characters 40-47:
1 | type 'a my_or_null : value_or_null = 'a or_null [@@or_null_reexport]
^^^^^^^
Error: Unbound type constructor "or_null"
Hint: Did you mean "my_or_null"?
|}]
Loading

0 comments on commit bff2e7d

Please sign in to comment.