-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix @this attribute dropping parens #7025
Changes from all commits
9a5c876
31228bf
0e3c3c1
82bfdb4
0b48963
3a12f8e
26a7a2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1591,9 +1591,13 @@ and print_label_declaration ~state (ld : Parsetree.label_declaration) cmt_tbl = | |
]) | ||
|
||
and print_typ_expr ~(state : State.t) (typ_expr : Parsetree.core_type) cmt_tbl = | ||
let parent_attrs = | ||
let attrs = ParsetreeViewer.filter_parsing_attrs typ_expr.ptyp_attributes in | ||
if Ast_uncurried.core_type_is_uncurried_fun typ_expr then attrs else [] | ||
in | ||
let print_arrow ?(arity = max_int) typ_expr = | ||
let attrs_before, args, return_type = | ||
ParsetreeViewer.arrow_type ~arity typ_expr | ||
ParsetreeViewer.arrow_type ~arity ~attrs:parent_attrs typ_expr | ||
in | ||
let return_type_needs_parens = | ||
match return_type.ptyp_desc with | ||
|
@@ -1841,6 +1845,8 @@ and print_typ_expr ~(state : State.t) (typ_expr : Parsetree.core_type) cmt_tbl = | |
in | ||
let should_print_its_own_attributes = | ||
match typ_expr.ptyp_desc with | ||
| Ptyp_constr _ when Ast_uncurried.core_type_is_uncurried_fun typ_expr -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let the attribute printing handled by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to add a task to remove dead code once uncurried is the only possible function type |
||
true | ||
| Ptyp_arrow _ (* es6 arrow types print their own attributes *) -> true | ||
| _ -> false | ||
in | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's where the issue lies, the
@this
attribute is attached to thePtyp_constr
notPtyp_arrow
. Essentially what I'm doing here is just picking up the attributes from thePtyp_constr
and pass it as the initial attrs for theParsetreeViewer.arrow_type
to work with.