File tree 3 files changed +28
-10
lines changed
3 files changed +28
-10
lines changed Original file line number Diff line number Diff line change @@ -1521,6 +1521,22 @@ let report_subtyping_error ppf env tr1 txt1 tr2 =
1521
1521
let tr1 = List. map prepare_expansion tr1
1522
1522
and tr2 = List. map prepare_expansion tr2 in
1523
1523
fprintf ppf " @[<v>%a" (trace true (tr2 = [] ) txt1) tr1;
1524
+ (match tr1 with
1525
+ | [(t1, _); (_, t2)] ->
1526
+ let a_runtime_representation = Runtime_representation. to_runtime_representation t2 env in
1527
+ let b_runtime_representation = Runtime_representation. to_runtime_representation t1 env in
1528
+ a_runtime_representation |> List. iter(
1529
+ fun a_value ->
1530
+ b_runtime_representation |> List. iter(
1531
+ fun b_value ->
1532
+ if Runtime_representation. runtime_values_match a_value b_value then (
1533
+ ()
1534
+ )
1535
+ else Runtime_representation. explain_why_not_matching a_value b_value
1536
+ |> List. iter(fun s -> fprintf ppf " @ %s" s)
1537
+ ))
1538
+ | _ -> ()
1539
+ );
1524
1540
if tr2 = [] then fprintf ppf " @]" else
1525
1541
let mis = mismatch tr2 in
1526
1542
fprintf ppf " %a%t@]"
Original file line number Diff line number Diff line change @@ -213,6 +213,14 @@ let rec to_runtime_representation (type_expr : Types.type_expr) (env : Env.t)
213
213
|> List. concat
214
214
| _ -> []
215
215
216
+ let explain_why_not_matching (a : runtime_js_value ) (b : runtime_js_value ) =
217
+ match (a, b) with
218
+ | StringLiteral {value = a_value } , StringLiteral {value = b_value } when a_value != b_value ->
219
+ [Printf. sprintf " The left hand is will be the string '%s' in runtime, and the right hand will be '%s'." b_value a_value]
220
+ | Any , _ -> [" We don't know what value left hand side would have at runtime." ]
221
+ | _ , Any -> [" We don't know what value right hand side would have at runtime." ]
222
+ | _ -> []
223
+
216
224
let runtime_values_match (a : runtime_js_value ) (b : runtime_js_value ) =
217
225
match (a, b) with
218
226
| StringLiteral {value = a_value } , StringLiteral {value = b_value } ->
Original file line number Diff line number Diff line change 1
- type x = [#One | #Two ]
1
+ type one = OK
2
+ type two = NOPE
2
3
3
- @tag ("kind" )
4
- type y = | @as ("one" ) One ({hello : [#hello ]}) | @as (null ) Two
4
+ let one : one = OK
5
5
6
- let x : x = #One
7
-
8
- let xx = #One ({"hello" : "hi" })
9
-
10
- let y : y = One ({hello : #hello })
11
-
12
- let z = (x :> y )
6
+ let two = (one :> two )
You can’t perform that action at this time.
0 commit comments