Conversation
|
I think that the fix belongs to the |
|
ok, thanks! fixed. |
| if pass = Compiler_pass.Typing && !print_types then true | ||
| else | ||
| match !stop_after with | ||
| | None -> false |
There was a problem hiding this comment.
With this implementation, -i has a higher priority than -stop-after.
A slightly different implementation would be to reverse the priority and let -i stop the compilation after typing only if stop_after was not set itself.
There was a problem hiding this comment.
The way I think of it, ideally -i should be decomposable in several simpler options, and in particular it implies -stop-after typing. Now if two different -stop-after <pass> are passed on the command-line, I would expect to stop at the earliest pass specified. This means that if -i -stop-after <pass> is specified, I would expect to stop at the earliest pass of typing and <pass>. Does that make sense?
There was a problem hiding this comment.
Currently, it's an error to pass two different -stop-after options.
Lines 1834 to 1843 in a5e1216
There was a problem hiding this comment.
Apropos #8938 (comment), remember that -i needs to decompose to three options (or there needs to be another micro-step before stop-after typing) to ensure that .cmi files are not written.
-i already has very high priority - it overrides both -c and -o (in the sense that ocamlopt -o foo foo.ml -i doesn't produce an executable or any other files).
There was a problem hiding this comment.
I didn't remember this, thanks! This suggests that we could also disallow passing -i and -stop-after at the same time. (But then that would suggest making the useful side-effect of -i available with for example a -dtypes or -dsignature option.) But personally I think that the intersection behavior would also be sensible, and better than giving priority to one option or the other.
Meta-level point: I personally don't care very strongly about what -i does or does not, it's a fairly minor feature that is probably not worth spending too much time on it. I applaud your (@gretay-js) care to leave the details of the command-line options well-rounded, but it would also probably be fine to leave it as is, or even slightly changed.
There was a problem hiding this comment.
This suggests that we could also disallow passing
-iand-stop-afterat the same time.
I considered it, but -i already silently ignores some other options, such as -c and -S, so it could also silently ignore -stop-after when pass is after Typing.
There was a problem hiding this comment.
Yes, I think it would be fine that way.
There was a problem hiding this comment.
Regarding the meta-level point, I agree with you in principle - the only problem is that there's an expectation that ocamlc -i foo.ml > foo.mli should give you a reasonable start for an .mli file (I can't remember if it's a valid one - i.e. if there are cases where it's not true). I don't know if any bad build systems have capitalised on that (and so might be broken by -i starting to produce other artefacts).
There was a problem hiding this comment.
ocamlbuild has a foo.inferred.mli target that creates the file using this process, but it is only invoked manually as a user-provided target, and in any case I don't think anything would break if .cmi files were suddenly produced. (I don't know if any build systems is able to track precisely which files are produced as a byproduct of certain command-line flag choices, but neither ocamlbuild nor make try it.)
|
I think this was OK in principle and is ready to go, right? |
|
Sorry, I had missed the fact that you did change the combined semantics of It may be a nitpick but I'm not sold on the implementation |
Yes, it is safer to check the order of passes here explicitly. I updated the PR. Thank you! |
gasche
left a comment
There was a problem hiding this comment.
I'm happy with the implementation.
|
Merged, thanks for the fix! |
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26)
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
ocaml#8938 from upstream trunk (cherry-pick 4353c75) ocaml#9090 from upstream trunk (cherry-pick fe7c8ed) ocaml#9097 from upstream trunk (cherry-pick 6daaf62) ocaml#8939 from gretay-js/save-linear (cherry-pick 1200de9) ocaml#9003 from gretay-js/start-from-emit (cherry-pick 21d5d26) Add linear_format to dune file Update .depend
With -i command line option, the compiler should stop after printing the interface, without generating any files. This behavior was broken by PR #8938, and this patch fixes it.