Skip to content

Commit 143eb00

Browse files
clef-mengasche
authored andcommitted
Add predefined type ['a atomic_loc].
This type will be used for ['a Atomic.Loc.t], as proposed in the RFC ocaml/RFCs#39 We implement this here to be able to use it in the stdlib later, after a bootstrap.
1 parent ff98b4f commit 143eb00

File tree

6 files changed

+25
-15
lines changed

6 files changed

+25
-15
lines changed

testsuite/tests/match-side-effects/check_partial.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ let lazy_needs_partial : _ * bool t ref -> int = function
7272
*match*/306 =o (field_mut 0 (field_imm 1 param/298)))
7373
(if (isint *match*/306) (if *match*/306 12 (exit 3)) (exit 3)))))
7474
with (3)
75-
(raise (makeblock 0 (global Match_failure/20!) [0: "" 1 49])))))
75+
(raise (makeblock 0 (global Match_failure/21!) [0: "" 1 49])))))
7676
(apply (field_mut 1 (global Toploop!)) "lazy_needs_partial"
7777
lazy_needs_partial/296))
7878
val lazy_needs_partial : unit lazy_t * bool t ref -> int = <fun>
@@ -91,7 +91,7 @@ let guard_total : bool t ref -> int = function
9191
(if (opaque 0) 1
9292
(let (*match*/385 =o (field_mut 0 param/384))
9393
(if (isint *match*/385) (if *match*/385 12 0)
94-
(raise (makeblock 0 (global Match_failure/20!) [0: "" 1 38])))))))
94+
(raise (makeblock 0 (global Match_failure/21!) [0: "" 1 38])))))))
9595
(apply (field_mut 1 (global Toploop!)) "guard_total" guard_total/307))
9696
val guard_total : bool t ref -> int = <fun>
9797
|}];;
@@ -111,7 +111,7 @@ let guard_needs_partial : bool t ref -> int = function
111111
with (9)
112112
(if (opaque 0) 1
113113
(if (isint *match*/389) 12
114-
(raise (makeblock 0 (global Match_failure/20!) [0: "" 1 46]))))))))
114+
(raise (makeblock 0 (global Match_failure/21!) [0: "" 1 46]))))))))
115115
(apply (field_mut 1 (global Toploop!)) "guard_needs_partial"
116116
guard_needs_partial/386))
117117
val guard_needs_partial : bool t ref -> int = <fun>

testsuite/tests/match-side-effects/partiality.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Warning 74 [degraded-to-partial-match]: This pattern-matching is compiled as
4949
(let (*match*/288 =o (field_mut 1 x/283))
5050
(if *match*/288 (field_imm 0 *match*/288)
5151
(raise
52-
(makeblock 0 (global Match_failure/20!) [0: "" 4 2])))))
52+
(makeblock 0 (global Match_failure/21!) [0: "" 4 2])))))
5353
1))
5454
0)))
5555
(apply (field_mut 1 (global Toploop!)) "f" f/281))
@@ -111,7 +111,7 @@ Warning 74 [degraded-to-partial-match]: This pattern-matching is compiled as
111111
(if *match*/303 (field_imm 0 *match*/303)
112112
(let (*match*/304 =o (field_mut 1 x/299))
113113
(if *match*/304
114-
(raise (makeblock 0 (global Match_failure/20!) [0: "" 2 2]))
114+
(raise (makeblock 0 (global Match_failure/21!) [0: "" 2 2]))
115115
1))))
116116
0)))
117117
(apply (field_mut 1 (global Toploop!)) "f" f/298))
@@ -160,7 +160,7 @@ Warning 74 [degraded-to-partial-match]: This pattern-matching is compiled as
160160
(let (*match*/312 =o (field_mut 0 (field_imm 0 *match*/308)))
161161
(if *match*/312 (field_imm 0 *match*/312)
162162
(raise
163-
(makeblock 0 (global Match_failure/20!) [0: "" 2 2]))))
163+
(makeblock 0 (global Match_failure/21!) [0: "" 2 2]))))
164164
3))))))
165165
(apply (field_mut 1 (global Toploop!)) "f" f/305))
166166
@@ -293,7 +293,7 @@ Warning 74 [degraded-to-partial-match]: This pattern-matching is compiled as
293293
*match*/354 =a (field_imm 1 *match*/352))
294294
(if *match*/354 (field_imm 0 *match*/354)
295295
(raise
296-
(makeblock 0 (global Match_failure/20!) [0: "" 2 2]))))
296+
(makeblock 0 (global Match_failure/21!) [0: "" 2 2]))))
297297
3))))))
298298
(apply (field_mut 1 (global Toploop!)) "deep" deep/342))
299299

testsuite/tests/match-side-effects/test_contexts_code.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ let example_1 () =
4444
case tag 0: (makeblock 0 (int) (field_imm 0 *match*/340))
4545
case tag 1:
4646
(raise
47-
(makeblock 0 (global Match_failure/20!)
47+
(makeblock 0 (global Match_failure/21!)
4848
[0: "contexts_1.ml" 17 2])))))
4949
case tag 1: [1: 2]))
5050
[1: 1]))))
@@ -91,7 +91,7 @@ let example_2 () =
9191
case tag 0: (makeblock 0 (int) (field_imm 0 *match*/358))
9292
case tag 1:
9393
(raise
94-
(makeblock 0 (global Match_failure/20!)
94+
(makeblock 0 (global Match_failure/21!)
9595
[0: "contexts_2.ml" 11 2])))))
9696
case tag 1: [1: 2]))
9797
[1: 1]))))

typing/predef.ml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type abstract_type_constr = [
4242
| `Lazy_t
4343
| `Extension_constructor
4444
| `Floatarray
45+
| `Atomic_loc
4546
]
4647
type data_type_constr = [
4748
| `Bool
@@ -56,7 +57,7 @@ type type_constr = [
5657
| data_type_constr
5758
]
5859

59-
let all_type_constrs = [
60+
let all_type_constrs : type_constr list = [
6061
`Int;
6162
`Char;
6263
`String;
@@ -76,6 +77,7 @@ let all_type_constrs = [
7677
`Lazy_t;
7778
`Extension_constructor;
7879
`Floatarray;
80+
`Atomic_loc;
7981
]
8082

8183
let ident_int = ident_create "int"
@@ -97,8 +99,9 @@ and ident_lazy_t = ident_create "lazy_t"
9799
and ident_string = ident_create "string"
98100
and ident_extension_constructor = ident_create "extension_constructor"
99101
and ident_floatarray = ident_create "floatarray"
102+
and ident_atomic_loc = ident_create "atomic_loc"
100103

101-
let ident_of_type_constr = function
104+
let ident_of_type_constr : type_constr -> Ident.t = function
102105
| `Int -> ident_int
103106
| `Char -> ident_char
104107
| `String -> ident_string
@@ -118,6 +121,7 @@ let ident_of_type_constr = function
118121
| `Lazy_t -> ident_lazy_t
119122
| `Extension_constructor -> ident_extension_constructor
120123
| `Floatarray -> ident_floatarray
124+
| `Atomic_loc -> ident_atomic_loc
121125

122126
let path_int = Pident ident_int
123127
and path_char = Pident ident_char
@@ -138,6 +142,7 @@ and path_lazy_t = Pident ident_lazy_t
138142
and path_string = Pident ident_string
139143
and path_extension_constructor = Pident ident_extension_constructor
140144
and path_floatarray = Pident ident_floatarray
145+
and path_atomic_loc = Pident ident_atomic_loc
141146

142147
let path_of_type_constr typ =
143148
Pident (ident_of_type_constr typ)
@@ -162,6 +167,7 @@ and type_lazy_t t = tconstr path_lazy_t [t]
162167
and type_string = tconstr path_string []
163168
and type_extension_constructor = tconstr path_extension_constructor []
164169
and type_floatarray = tconstr path_floatarray []
170+
and type_atomic_loc t = tconstr path_atomic_loc [t]
165171

166172
let find_type_constr =
167173
let all_predef_paths =
@@ -300,7 +306,9 @@ let decl_of_type_constr tconstr =
300306
| `Continuation ->
301307
let variance = Variance.(contravariant, covariant) in
302308
decl2 ~variance ()
303-
| `Array ->
309+
| `Array
310+
| `Atomic_loc
311+
->
304312
decl1 ~variance:Variance.full ()
305313
| `List ->
306314
let kind tvar =

typing/predef.mli

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type abstract_type_constr = [
3131
| `Lazy_t
3232
| `Extension_constructor
3333
| `Floatarray
34+
| `Atomic_loc
3435
]
3536
type data_type_constr = [
3637
| `Bool
@@ -64,8 +65,9 @@ val type_nativeint: type_expr
6465
val type_int32: type_expr
6566
val type_int64: type_expr
6667
val type_lazy_t: type_expr -> type_expr
67-
val type_extension_constructor:type_expr
68-
val type_floatarray:type_expr
68+
val type_extension_constructor: type_expr
69+
val type_floatarray: type_expr
70+
val type_atomic_loc: type_expr -> type_expr
6971

7072
val path_int: Path.t
7173
val path_char: Path.t

typing/typeopt.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ let classify env ty : classification =
9797
| Some (`String | `Bytes
9898
| `Int32 | `Int64 | `Nativeint
9999
| `Extension_constructor | `Continuation
100-
| `Array | `Floatarray)
100+
| `Array | `Floatarray | `Atomic_loc)
101101
-> Addr
102102
| Some #Predef.data_type_constr | None ->
103103
try

0 commit comments

Comments
 (0)