Skip to content

#14629: update is_inferred to traverse local opens#14638

Merged
nojb merged 2 commits intoocaml:trunkfrom
Octachron:fix_rev_apply
Mar 10, 2026
Merged

#14629: update is_inferred to traverse local opens#14638
nojb merged 2 commits intoocaml:trunkfrom
Octachron:fix_rev_apply

Conversation

@Octachron
Copy link
Copy Markdown
Member

This PR restores the inlining of |> in x |> M.(f y) by preserving the previous behaviour of the is_inferred function in this specific case.

I had considered making this function traverses all Pexp_structure_item _ but the function feels quite adhoc to me, and thus preserving the previous behaviour seems like a good first step.

Fixes #14629
cc @nojb

Copy link
Copy Markdown
Contributor

@nojb nojb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @Octachron for the speedy fix!

| Pexp_coerce _ | Pexp_send _ | Pexp_new _ | Pexp_pack (_, Some _) -> true
| Pexp_sequence (_, e) -> is_inferred e
| Pexp_ifthenelse (_, e1, Some e2) -> is_inferred e1 && is_inferred e2
| Pexp_struct_item( { pstr_desc= Pstr_open _; _ }, e ) -> is_inferred e
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment may be useful to a future reader to underestand why we only treat this case here.

Suggested change
| Pexp_struct_item( { pstr_desc= Pstr_open _; _ }, e ) -> is_inferred e
| Pexp_struct_item( { pstr_desc= Pstr_open _; _ }, e ) -> is_inferred e (* PR #14638 *)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment with a link to the issue which seemed more informative than this PR.

@Octachron Octachron changed the title #14629: update is_inferred to traverse Pexp_structure_item #14629: update is_inferred to traverse local opens Mar 10, 2026
@nojb nojb merged commit 7c51f06 into ocaml:trunk Mar 10, 2026
26 checks passed
nojb pushed a commit that referenced this pull request Mar 10, 2026
* type: update is_inferred to traverse Pexp_structure_item

* review: comment

(cherry picked from commit 7c51f06)
@nojb
Copy link
Copy Markdown
Contributor

nojb commented Mar 10, 2026

Cherry-picked to 5.5 8633136

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[5.5] Local open changes the typechecker behaviour regarding optional argument elimination

2 participants