Alpha: do not catch runtime exceptions
This commit is contained in:
parent
ec648f5397
commit
a8b2ab325e
@ -141,9 +141,10 @@ let parse_annots loc ?(allow_special_var = false) ?(allow_special_field = false)
|
||||
else error (Unexpected_annotation loc)
|
||||
| _ -> error (Unexpected_annotation loc) in
|
||||
List.fold_left (fun acc s ->
|
||||
match acc with
|
||||
| Ok acc ->
|
||||
begin match s.[0] with
|
||||
acc >>? fun acc ->
|
||||
if Compare.Int.(String.length s = 0) then
|
||||
error (Unexpected_annotation loc)
|
||||
else match s.[0] with
|
||||
| ':' -> sub_or_wildcard ~specials:[] (fun a -> `Type_annot a) s acc
|
||||
| '@' ->
|
||||
sub_or_wildcard
|
||||
@ -153,9 +154,6 @@ let parse_annots loc ?(allow_special_var = false) ?(allow_special_field = false)
|
||||
~specials:(if allow_special_field then ['@'] else [])
|
||||
(fun a -> `Field_annot a) s acc
|
||||
| _ -> error (Unexpected_annotation loc)
|
||||
| exception Invalid_argument _ -> error (Unexpected_annotation loc)
|
||||
end
|
||||
| Error _ -> acc
|
||||
) (ok []) l
|
||||
>|? List.rev
|
||||
|
||||
@ -273,10 +271,8 @@ let extract_field_annot
|
||||
= function
|
||||
| Prim (loc, prim, args, annot) ->
|
||||
let field_annots, annot = List.partition (fun s ->
|
||||
match s.[0] with
|
||||
| '%' -> true
|
||||
| _ -> false
|
||||
| exception Invalid_argument _ -> false
|
||||
Compare.Int.(String.length s > 0) &&
|
||||
Compare.Char.(s.[0] = '%')
|
||||
) annot in
|
||||
parse_field_annot loc field_annots >|? fun field_annot ->
|
||||
Prim (loc, prim, args, annot), field_annot
|
||||
|
Loading…
Reference in New Issue
Block a user