@@ -4,25 +4,29 @@ open Fiber.O
4
4
let action_kind = " type-annotate"
5
5
6
6
let check_typeable_context pipeline pos_start =
7
+ let open Typedtree in
7
8
let pos_start = Mpipeline. get_lexing_pos pipeline pos_start in
8
9
let typer = Mpipeline. typer_result pipeline in
9
10
let browse = Mbrowse. of_typedtree (Mtyper. get_typedtree typer) in
10
11
let is_exp_constrained = function
11
- | Typedtree. Texp_constraint _ , _ , _ -> true
12
- | Typedtree. Texp_coerce (Some _ , _ ), _ , _ -> true
12
+ | Texp_constraint _ , _ , _ -> true
13
+ | Texp_coerce (Some _ , _ ), _ , _ -> true
13
14
| _ -> false
14
15
in
15
16
let is_pat_constrained = function
16
- | Typedtree. Tpat_constraint _ , _ , _ -> true
17
+ | Tpat_constraint _ , _ , _ -> true
17
18
| _ -> false
18
19
in
19
20
let is_valid p extras =
20
21
if List. exists ~f: p extras then `Invalid else `Valid
21
22
in
22
23
match Mbrowse. enclosing pos_start [ browse ] with
24
+ | (_, Pattern { pat_desc = Tpat_var _; _})
25
+ :: (_, Value_binding { vb_expr = { exp_desc = Texp_function _; _} ; _ })
26
+ :: _ -> `Invalid (* TODO: traverse function arguments *)
23
27
| (_ , Expression e ) :: _ -> is_valid is_exp_constrained e.exp_extra
24
- | (_, Pattern { pat_desc = Typedtree. Tpat_any ; _ })
25
- :: (_, Pattern { pat_desc = Typedtree. Tpat_alias _; pat_extra; _ })
28
+ | (_, Pattern { pat_desc = Tpat_any ; _ })
29
+ :: (_, Pattern { pat_desc = Tpat_alias _; pat_extra; _ })
26
30
:: _ -> is_valid is_pat_constrained pat_extra
27
31
| (_ , Pattern p ) :: _ -> is_valid is_pat_constrained p.pat_extra
28
32
| _ :: _ | [] -> `Invalid
0 commit comments