@@ -2423,10 +2423,14 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp
2423
2423
begin_def () ;
2424
2424
let total_app = not partial in
2425
2425
let type_clash_context = type_clash_context_from_function sexp sfunct in
2426
+ let _ = translate_unified_ops in
2426
2427
let args, ty_res, fully_applied =
2427
- match translate_unified_ops env funct sargs with
2428
- | Some (targs , result_type ) -> (targs, result_type, true )
2429
- | None -> type_application ?type_clash_context total_app env funct sargs
2428
+ if false then
2429
+ type_application ?type_clash_context total_app env funct sargs
2430
+ else
2431
+ match translate_unified_ops env funct sargs with
2432
+ | Some (targs , result_type ) -> (targs, result_type, true )
2433
+ | None -> type_application ?type_clash_context total_app env funct sargs
2430
2434
in
2431
2435
end_def () ;
2432
2436
unify_var env (newvar () ) funct.exp_type;
@@ -3379,22 +3383,22 @@ and translate_unified_ops (env : Env.t) (funct : Typedtree.expression)
3379
3383
let result_type =
3380
3384
match (lhs_type.desc, specialization) with
3381
3385
| Tconstr (path , _ , _ ), _ when Path. same path Predef. path_int ->
3382
- Predef. type_int
3386
+ instance_def Predef. type_int
3383
3387
| Tconstr (path, _, _), {bool = Some _}
3384
3388
when Path. same path Predef. path_bool ->
3385
- Predef. type_bool
3389
+ instance_def Predef. type_bool
3386
3390
| Tconstr (path, _, _), {float = Some _}
3387
3391
when Path. same path Predef. path_float ->
3388
- Predef. type_float
3392
+ instance_def Predef. type_float
3389
3393
| Tconstr (path, _, _), {bigint = Some _}
3390
3394
when Path. same path Predef. path_bigint ->
3391
- Predef. type_bigint
3395
+ instance_def Predef. type_bigint
3392
3396
| Tconstr (path, _, _), {string = Some _}
3393
3397
when Path. same path Predef. path_string ->
3394
- Predef. type_string
3398
+ instance_def Predef. type_string
3395
3399
| _ ->
3396
- unify env lhs_type Predef. type_int;
3397
- Predef. type_int
3400
+ unify env lhs_type (instance_def Predef. type_int) ;
3401
+ instance_def Predef. type_int
3398
3402
in
3399
3403
let targs = [(to_noloc lhs_label, Some lhs)] in
3400
3404
Some (targs, result_type)
@@ -3409,50 +3413,50 @@ and translate_unified_ops (env : Env.t) (funct : Typedtree.expression)
3409
3413
match (lhs_type.desc, specialization) with
3410
3414
| Tconstr (path , _ , _ ), _ when Path. same path Predef. path_int ->
3411
3415
let rhs = type_expect env rhs_expr Predef. type_int in
3412
- (lhs, rhs, Predef. type_int)
3416
+ (lhs, rhs, instance_def Predef. type_int)
3413
3417
| Tconstr (path, _, _), {bool = Some _}
3414
3418
when Path. same path Predef. path_bool ->
3415
3419
let rhs = type_expect env rhs_expr Predef. type_bool in
3416
- (lhs, rhs, Predef. type_bool)
3420
+ (lhs, rhs, instance_def Predef. type_bool)
3417
3421
| Tconstr (path, _, _), {float = Some _}
3418
3422
when Path. same path Predef. path_float ->
3419
3423
let rhs = type_expect env rhs_expr Predef. type_float in
3420
- (lhs, rhs, Predef. type_float)
3424
+ (lhs, rhs, instance_def Predef. type_float)
3421
3425
| Tconstr (path, _, _), {bigint = Some _}
3422
3426
when Path. same path Predef. path_bigint ->
3423
3427
let rhs = type_expect env rhs_expr Predef. type_bigint in
3424
- (lhs, rhs, Predef. type_bigint)
3428
+ (lhs, rhs, instance_def Predef. type_bigint)
3425
3429
| Tconstr (path, _, _), {string = Some _}
3426
3430
when Path. same path Predef. path_string ->
3427
3431
let rhs = type_expect env rhs_expr Predef. type_string in
3428
- (lhs, rhs, Predef. type_string)
3432
+ (lhs, rhs, instance_def Predef. type_string)
3429
3433
| _ -> (
3430
3434
(* Rule 2. Try unifying to rhs *)
3431
3435
match (rhs_type.desc, specialization) with
3432
3436
| Tconstr (path , _ , _ ), _ when Path. same path Predef. path_int ->
3433
3437
let lhs = type_expect env lhs_expr Predef. type_int in
3434
- (lhs, rhs, Predef. type_int)
3438
+ (lhs, rhs, instance_def Predef. type_int)
3435
3439
| Tconstr (path, _, _), {bool = Some _}
3436
3440
when Path. same path Predef. path_bool ->
3437
3441
let lhs = type_expect env lhs_expr Predef. type_bool in
3438
- (lhs, rhs, Predef. type_bool)
3442
+ (lhs, rhs, instance_def Predef. type_bool)
3439
3443
| Tconstr (path, _, _), {float = Some _}
3440
3444
when Path. same path Predef. path_float ->
3441
3445
let lhs = type_expect env lhs_expr Predef. type_float in
3442
- (lhs, rhs, Predef. type_float)
3446
+ (lhs, rhs, instance_def Predef. type_float)
3443
3447
| Tconstr (path, _, _), {bigint = Some _}
3444
3448
when Path. same path Predef. path_bigint ->
3445
3449
let lhs = type_expect env lhs_expr Predef. type_bigint in
3446
- (lhs, rhs, Predef. type_bigint)
3450
+ (lhs, rhs, instance_def Predef. type_bigint)
3447
3451
| Tconstr (path, _, _), {string = Some _}
3448
3452
when Path. same path Predef. path_string ->
3449
3453
let lhs = type_expect env lhs_expr Predef. type_string in
3450
- (lhs, rhs, Predef. type_string)
3454
+ (lhs, rhs, instance_def Predef. type_string)
3451
3455
| _ ->
3452
3456
(* Rule 3. Fallback to int *)
3453
3457
let lhs = type_expect env lhs_expr Predef. type_int in
3454
3458
let rhs = type_expect env rhs_expr Predef. type_int in
3455
- (lhs, rhs, Predef. type_int))
3459
+ (lhs, rhs, instance_def Predef. type_int))
3456
3460
in
3457
3461
let targs =
3458
3462
[(to_noloc lhs_label, Some lhs); (to_noloc rhs_label, Some rhs)]
0 commit comments