File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -3969,8 +3969,8 @@ let rec subtype_rec env trace t1 t2 cstrs =
39693969 let label_decl_sub (acc1 , acc2 ) ld2 =
39703970 match Ext_list. find_first fields1 (fun ld1 -> ld1.ld_id.name = ld2.ld_id.name) with
39713971 | Some ld1 ->
3972- if field_is_optional ld1.ld_id repr1 && not (field_is_optional ld2.ld_id repr2) then
3973- (* optional field can't be cast to non-optional one *)
3972+ if field_is_optional ld1.ld_id repr1 <> (field_is_optional ld2.ld_id repr2) then
3973+ (* optional field can't be modified *)
39743974 violation := true ;
39753975 let get_as (({txt} , payload ) : Parsetree. attribute ) =
39763976 if txt = " as" then Ast_payload. is_single_string payload
Original file line number Diff line number Diff line change @@ -6,14 +6,14 @@ type r3 = {a?: int}
66
77type r4 = {}
88
9- let _ = (x : r1 ) => (x :> r2 ) // Convert a from mandatory to optional
9+ // let _ = (x: r1) => (x :> r2) // Convert a from mandatory to optional NOT ALLOWED
1010// let _ = (x: r2) => (x :> r1) can't turn an optional field to a mandatory one
1111let _ = (x : r2 ) => (x :> r3 ) // can omit field
12- let _ = (x : r1 ) => (x :> r3 ) // omit field and convert from mandatory to optional
12+ // let _ = (x: r1) => (x :> r3) // omit field and convert from mandatory to optional NOT ALLOWED
1313let _ = (x : r3 ) => (x :> r4 ) // omit everything
1414
15- type nested1 = {n : r1 , extra : int }
16- type nested2 = {n : r2 }
15+ type nested1 = {n : r2 , extra : int }
16+ type nested2 = {n : r3 }
1717let _ = (x : nested1 ) => (x :> nested2 )
1818
1919module TestInlining = {
You can’t perform that action at this time.
0 commit comments