Skip to content
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

Prevent warning 59 from triggering on Lazy of constants #714

Merged
merged 2 commits into from
Aug 1, 2016

Conversation

chambart
Copy link
Contributor

Lazy.force (lazy (fun x -> x)) was triggering this warning because the
code generated by Lazy.force modifies its argument in a dead branch.
This allows to recognize this branch as dead, and eliminate it.

@chambart
Copy link
Contributor Author

@lpw25
Copy link
Contributor

lpw25 commented Jul 25, 2016

This looks correct to me, but I find the double-checking of the argument approximation for the common cases a bit ugly (checked once inside potentially_taken_*_switch_branch and then again in the match statement in inline_and_simplify.ml). Couldn't the potentially_taken_... functions return something which directly represents how inline_and_simplify.ml should handle it.

@chambart
Copy link
Contributor Author

Yes that saddened me too. But maybe returning

type compatibility =
  | Incompatible (* Cannot be that case *)
  | Compatible    (* Can be that case but can be other cases *)
  | Selected         (* Can be that case and cannot be any other case *)

can help lighten the code. I'll give it a try.

(* In theory symbol cannot contain integers but this shouldn't
matter as this will always be an imported approximation *)
true

Copy link
Contributor

Choose a reason for hiding this comment

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

No blank lines in functions please!

Copy link
Contributor

@alainfrisch alainfrisch Jul 26, 2016

Choose a reason for hiding this comment

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

It we are discussing style, I'd suggest to drop the custom .ocp-indent in middle-end/ and adopt the global configuration. I find the lack of extra indentation for pattern matching "actions" (w.r.t. the pattern) makes the code much harder to read. I would also suggest to drop useless parentheses around or-patterns.

@mshinwell
Copy link
Contributor

@chambart Maybe try to make the constructor names sufficiently descriptive that you don't need the comments in the type declaration?

@chambart
Copy link
Contributor Author

@lpw25, @mshinwell Is that better ? Do you approve it now ?

@alainfrisch alainfrisch added this to the 4.04 milestone Jul 31, 2016
Lazy.force (lazy (fun x -> x)) was triggering this warning because the
code generated by Lazy.force modifies its argument in a dead branch.
This allows to recognize this branch as dead, and eliminate it.
@chambart
Copy link
Contributor Author

Rebased

@lpw25
Copy link
Contributor

lpw25 commented Aug 1, 2016

This looks correct to me. Merging.

@lpw25 lpw25 merged commit 51f58a6 into ocaml:trunk Aug 1, 2016
camlspotter pushed a commit to camlspotter/ocaml that referenced this pull request Oct 17, 2017
Prevent warning 59 from triggering on Lazy of constants
stedolan pushed a commit to stedolan/ocaml that referenced this pull request Sep 21, 2022
EmileTrotignon pushed a commit to EmileTrotignon/ocaml that referenced this pull request Jan 12, 2024
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.

4 participants