Skip to content

MPR#7702: refresh raise counts when inlining a function#1553

Merged
gasche merged 6 commits intoocaml:trunkfrom
xclerc:mpr7702
Jan 9, 2018
Merged

MPR#7702: refresh raise counts when inlining a function#1553
gasche merged 6 commits intoocaml:trunkfrom
xclerc:mpr7702

Conversation

@xclerc
Copy link
Contributor

@xclerc xclerc commented Jan 2, 2018

Following the suggestion from @lthls in Mantis#7702, here is a tentative fix.

As the title suggests, it simply refreshes raise counts to ensure there is no clash
when a function is inlined. A new parameter, namely rn, is added to the substitute
function; its type is (int, int) Tbl.t option (None indicating that counts should not
be refreshed).

@gasche
Copy link
Member

gasche commented Jan 4, 2018

@lthls: would you by chance be willing to review it (if you believe it is correct, feel free to "approve" the PR.)?

Copy link
Contributor

@lthls lthls left a comment

Choose a reason for hiding this comment

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

This patch looks correct to me, so I approve it on this basis.
However, it would be nice to have added the example from MPR#7702 to the testsuite, and the comment starting at line 502 should probably be updated.

Ustaticfail (nfail, List.map (substitute loc fpc sb) args)
let nfail =
match rn with
| Some rn -> (try Tbl.find nfail rn with Not_found -> nfail)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit surprised by the try-with statement. In my version it was needed for the let-rec case, but since you only use a renaming for inlining direct applications I believe it should be an error if nfail isn't bound in rn.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed - replaced the exception handler with a fatal error.

Copy link
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

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

I'm "approving" on the basis of @lthls' review, I have not looked at the patch myself but I trust the review. @xclerc, feel free to rebase (if necessary) and merge.

@xclerc
Copy link
Contributor Author

xclerc commented Jan 9, 2018

No need to rebase; can I let you merge?

@gasche
Copy link
Member

gasche commented Jan 9, 2018

The CI is failing because you need a Changes entry.

@xclerc
Copy link
Contributor Author

xclerc commented Jan 9, 2018

Here it is.

Changes Outdated
(Jacques Garrigue, report by Nicolas Ojeda Bar)

- MPR#7702, GPR#1553: refresh raise counts when inlining a function
(Vincent Laviron, Xavier Clerc, report by Cheng Sun, review by Gabriel Scherer)
Copy link
Member

Choose a reason for hiding this comment

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

please remove my name, I haven't reviewed this PR -- I merely passed @lthls' approval.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK; I thought the reviewer was the one adding the green badge to a PR.

Copy link
Member

Choose a reason for hiding this comment

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

The green badge should only happen after serious review work has been performed, and in general the two people coincide (reviewing and badging), but not in this particular case. In general "review by" is useful to credit everyone who contributed useful comments during the review period.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood; could you squash/merge?

@gasche gasche merged commit 4b352df into ocaml:trunk Jan 9, 2018
@hhugo
Copy link
Contributor

hhugo commented Jan 9, 2018

What about back-porting to 4.06 ?

@xclerc xclerc deleted the mpr7702 branch January 10, 2018 11:26
xclerc added a commit to janestreet/ocaml that referenced this pull request Jan 10, 2018
xclerc added a commit to janestreet/ocaml that referenced this pull request Jan 10, 2018
MPR#7702: refresh raise counts when inlining a function (ocaml#1553)
@damiendoligez
Copy link
Member

Cherry-picked to 4.06 (2fb8481).

Note to self and @gasche : there will be a risk of duplicate entry in Changes when we merge the branch.

@lthls lthls mentioned this pull request May 3, 2019
rajgodse added a commit to rajgodse/ocaml that referenced this pull request Aug 18, 2023
* Adds guard type to Parsetree

* Pattern guards parsing implemented

* format: remove parens

Co-authored-by: Nick Roberts <[email protected]>

* formatting fixes

* test documentation

* removes ast dump from tests

* match precedence CR

* removed catch-all case from guard match

---------

Co-authored-by: Nick Roberts <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants