Skip to content

Commit 987ba8a

Browse files
committed
upgrade flow parser
1 parent 3291815 commit 987ba8a

35 files changed

+146128
-271311
lines changed

jscomp/frontend/classify_function.ml

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ let rec is_obj_literal (x : _ Flow_ast.Expression.t) : bool =
2929
| Object { properties } -> Ext_list.for_all properties is_literal_kv
3030
| Array { elements } ->
3131
Ext_list.for_all elements (fun x ->
32-
match x with
33-
| None -> true
34-
| Some (Expression x) -> is_obj_literal x
35-
| Some _ -> false)
32+
match x with Expression x -> is_obj_literal x | _ -> false)
3633
| _ -> false
3734

3835
and is_literal_kv (x : _ Flow_ast.Expression.Object.property) =
@@ -66,9 +63,10 @@ let classify_exp (prog : _ Flow_ast.Expression.t) : Js_raw_info.exp =
6663
let comment =
6764
match comments with
6865
| None -> None
69-
| Some { leading = [ (_, Block comment) ] } ->
66+
| Some { leading = [ (_, { kind = Block; text = comment }) ] } ->
7067
Some ("/*" ^ comment ^ "*/")
71-
| Some { leading = [ (_, Line comment) ] } -> Some ("//" ^ comment)
68+
| Some { leading = [ (_, { kind = Line; text = comment }) ] } ->
69+
Some ("//" ^ comment)
7270
| Some _ -> None
7371
in
7472
Js_literal { comment }
@@ -96,7 +94,9 @@ let classify ?(check : (Location.t * int) option) (prog : string) :
9694

9795
let classify_stmt (prog : string) : Js_raw_info.stmt =
9896
let result = Parser_flow.parse_program false None prog in
99-
match fst result with _loc, [], _ -> Js_stmt_comment | _ -> Js_stmt_unknown
97+
match fst result with
98+
| _loc, { statements = [] } -> Js_stmt_comment
99+
| _ -> Js_stmt_unknown
100100
(* we can also analayze throw
101101
x.x pure access
102102
*)

0 commit comments

Comments
 (0)