File tree Expand file tree Collapse file tree 4 files changed +41
-11
lines changed
testsuite/tests/typing-local Expand file tree Collapse file tree 4 files changed +41
-11
lines changed Original file line number Diff line number Diff line change @@ -1630,11 +1630,20 @@ Error: This value escapes its region
1630
1630
1631
1631
(* Poly-moded eta expansion *)
1632
1632
module Heap32 : sig val add : int32 -> int32 -> int32 end = Int32
1633
+ module Heap32E : sig external add : int32 -> int32 -> int32 = "%int32_add" end = Int32
1633
1634
module Local32 : sig val add : local_ int32 -> local_ int32 -> local_ int32 end = Int32
1635
+ module Local32E : sig external add : local_ int32 -> local_ int32 -> local_ int32 = "%int32_add" end = Int32
1634
1636
[%%expect{|
1635
1637
module Heap32 : sig val add : int32 -> int32 -> int32 end
1638
+ module Heap32E :
1639
+ sig external add : int32 -> int32 -> int32 = "%int32_add" end
1636
1640
module Local32 :
1637
1641
sig val add : local_ int32 -> local_ int32 -> local_ int32 end
1642
+ module Local32E :
1643
+ sig
1644
+ external add : local_ int32 -> local_ int32 -> local_ int32
1645
+ = "%int32_add"
1646
+ end
1638
1647
|}]
1639
1648
module Bad32 : sig val add : local_ int32 -> local_ int32 -> int32 end =
1640
1649
struct let add = Int32.add end
Original file line number Diff line number Diff line change @@ -36,17 +36,27 @@ let value_descriptions ~loc env name
36
36
match vd1.val_kind with
37
37
| Val_prim p1 ->
38
38
let ty1, mode1 = Ctype. instance_prim_mode p1 vd1.val_type in
39
- if Ctype. moregeneral env true ty1 vd2.val_type then begin
40
- match vd2.val_kind with
41
- Val_prim p2 ->
42
- if p1 = p2 then Tcoerce_none else raise Dont_match
43
- | _ ->
44
- let pc =
45
- {pc_desc = p1; pc_type = vd2.Types. val_type; pc_poly_mode = mode1;
46
- pc_env = env; pc_loc = vd1.Types. val_loc; } in
47
- Tcoerce_primitive pc
48
- end else
49
- raise Dont_match
39
+ begin match vd2.val_kind with
40
+ | Val_prim p2 ->
41
+ let ty2, _mode2 = Ctype. instance_prim_mode p2 vd2.val_type in
42
+ if not (Ctype. moregeneral env true ty1 ty2) then
43
+ raise Dont_match ;
44
+ let mode1 : Primitive.mode =
45
+ match Btype.Alloc_mode. check_const mode1 with
46
+ | Some Global -> Prim_global
47
+ | Some Local -> Prim_local
48
+ | None -> Prim_poly
49
+ in
50
+ let p1 = Primitive. inst_mode mode1 p1 in
51
+ if p1 = p2 then Tcoerce_none else raise Dont_match
52
+ | _ ->
53
+ if not (Ctype. moregeneral env true ty1 vd2.val_type) then
54
+ raise Dont_match ;
55
+ let pc =
56
+ {pc_desc = p1; pc_type = vd2.Types. val_type; pc_poly_mode = mode1;
57
+ pc_env = env; pc_loc = vd1.Types. val_loc; } in
58
+ Tcoerce_primitive pc
59
+ end
50
60
| _ ->
51
61
if Ctype. moregeneral env true vd1.val_type vd2.val_type then begin
52
62
match vd2.val_kind with
Original file line number Diff line number Diff line change @@ -275,6 +275,15 @@ let native_name_is_external p =
275
275
let nat_name = native_name p in
276
276
nat_name <> " " && nat_name.[0 ] <> '%'
277
277
278
+ let inst_mode mode p =
279
+ let inst_repr = function
280
+ | Prim_poly , r -> mode, r
281
+ | (Prim_global |Prim_local ) as m , r -> m, r
282
+ in
283
+ { p with
284
+ prim_native_repr_args = List. map inst_repr p.prim_native_repr_args;
285
+ prim_native_repr_res = inst_repr p.prim_native_repr_res }
286
+
278
287
let report_error ppf err =
279
288
match err with
280
289
| Old_style_float_with_native_repr_attribute ->
Original file line number Diff line number Diff line change @@ -88,6 +88,8 @@ val byte_name: description -> string
88
88
compiler itself. *)
89
89
val native_name_is_external : description -> bool
90
90
91
+ val inst_mode : mode -> description -> description
92
+
91
93
type error =
92
94
| Old_style_float_with_native_repr_attribute
93
95
| Old_style_noalloc_with_noalloc_attribute
You can’t perform that action at this time.
0 commit comments