Skip to content

Commit 31228bf

Browse files
committed
Check for existence of attr and arity
Check for existence of attr at Ptyp_constr (function$) as the @this attribute is attached to the Ptyp_constr, not the Ptyp_arrow.
1 parent 9a5c876 commit 31228bf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

jscomp/syntax/src/res_printer.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,14 @@ and print_label_declaration ~state (ld : Parsetree.label_declaration) cmt_tbl =
15911591
])
15921592

15931593
and print_typ_expr ~(state : State.t) (typ_expr : Parsetree.core_type) cmt_tbl =
1594-
let parent_has_attrs = Ast_uncurried.core_type_is_uncurried_fun typ_expr && not (typ_expr.ptyp_attributes = []) in
1594+
let parent_has_attrs =
1595+
let attrs = ParsetreeViewer.filter_parsing_attrs typ_expr.ptyp_attributes in
1596+
if Ast_uncurried.core_type_is_uncurried_fun typ_expr && not (attrs = [])
1597+
then
1598+
let arity, _ = Ast_uncurried.core_type_extract_uncurried_fun typ_expr in
1599+
arity > 0
1600+
else false
1601+
in
15951602
let print_arrow ?(arity = max_int) typ_expr =
15961603
let attrs_before, args, return_type =
15971604
ParsetreeViewer.arrow_type ~arity typ_expr

0 commit comments

Comments
 (0)