File tree 2 files changed +47
-5
lines changed
testsuite/tests/typing-modes
2 files changed +47
-5
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,50 @@ let _ = with_global_effect (fun k -> let _ = Mk4 k in ())
126
126
- : unit = ()
127
127
| }]
128
128
129
+ (* Externals and [yielding ]: * )
130
+
131
+ external ok_yielding : 'a @ local -> unit = " %ignore"
132
+
133
+ let _ = ok_yielding 4
134
+
135
+ let _ = ok_yielding (stack_ (Some " local string" ))
136
+
137
+ let _ = with_global_effect (fun k -> ok_yielding k)
138
+
139
+ [%% expect{|
140
+ external ok_yielding : local_ 'a -> unit = " %ignore"
141
+ - : unit = ()
142
+ - : unit = ()
143
+ - : unit = ()
144
+ |}]
145
+
146
+ external requires_unyielding : 'a @ local unyielding -> unit = " %ignore"
147
+
148
+ let _ = requires_unyielding 4
149
+
150
+ let _ = requires_unyielding (stack_ (Some " local string" ))
151
+
152
+ let _ = with_global_effect (fun k -> requires_unyielding k)
153
+
154
+ [%% expect{|
155
+ external requires_unyielding : local_ 'a @ unyielding -> unit = " %ignore"
156
+ - : unit = ()
157
+ - : unit = ()
158
+ Line 7 , characters 57-58 :
159
+ 7 | let _ = with_global_effect (fun k -> requires_unyielding k)
160
+ ^
161
+ Error : This value is " yielding" but expected to be " unyielding" .
162
+ | }]
163
+
164
+ external returns_unyielding : 'a -> 'a @ local unyielding = " %identity"
165
+
166
+ let _ = requires_unyielding (returns_unyielding " some string" )
167
+
168
+ [%% expect{|
169
+ external returns_unyielding : 'a -> local_ 'a @ unyielding = " %identity"
170
+ - : unit = ()
171
+ |}]
172
+
129
173
(* [@local_opt] and [yielding]: *)
130
174
131
175
external id : ('a [@ local_opt]) -> ('a [@ local_opt]) = " %identity"
Original file line number Diff line number Diff line change @@ -1663,14 +1663,12 @@ let instance_label ~fixed lbl =
1663
1663
)
1664
1664
1665
1665
(* CR dkalinichenko: we must vary yieldingness together with locality to get
1666
- sane behavior around defaults . Remove once we have mode polymorphism. *)
1666
+ sane behavior around [@local_opt] . Remove once we have mode polymorphism. *)
1667
1667
let prim_mode mvar mvar' = function
1668
1668
| Primitive. Prim_global , _ ->
1669
- Locality. allow_right Locality. global,
1670
- Yielding. allow_right Yielding. unyielding
1669
+ Locality. allow_right Locality. global, Yielding. newvar ()
1671
1670
| Primitive. Prim_local , _ ->
1672
- Locality. allow_right Locality. local,
1673
- Yielding. allow_right Yielding. yielding
1671
+ Locality. allow_right Locality. local, Yielding. newvar ()
1674
1672
| Primitive. Prim_poly , _ ->
1675
1673
match mvar, mvar' with
1676
1674
| Some mvar , Some mvar' -> mvar, mvar'
You can’t perform that action at this time.
0 commit comments