-
Notifications
You must be signed in to change notification settings - Fork 469
Test for issue #7454: fmt triggers menhir #7455
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
Merged
emillon
merged 3 commits into
ocaml:main
from
voodoos:issue-formatting-generate-menhir-parser
Apr 5, 2023
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| See issue 7454 | ||
|
|
||
| $ cat >parser_raw.mly <<EOF | ||
| > %token EOL | ||
| > %start <unit> prog | ||
| > %% | ||
| > prog: | ||
| > | EOL { () } | ||
| > | EOL; prog { () } | ||
| > EOF | ||
|
|
||
| $ cat >dune <<EOF | ||
| > (library | ||
| > (name foo) | ||
| > (modules parser_raw other_gen)) | ||
| > | ||
| > (menhir | ||
| > (modules parser_raw) | ||
| > (mode promote)) | ||
| > | ||
| > (rule | ||
| > (targets other_gen.ml) | ||
| > (mode promote) | ||
| > (action (with-stdout-to %{targets} | ||
| > (echo "print_int 42")))) | ||
| > EOF | ||
|
|
||
| $ cat >dune-project <<EOF | ||
| > (lang dune 2.9) | ||
| > (using menhir 2.0) | ||
| > (formatting (enabled_for ocaml)) | ||
| > EOF | ||
|
|
||
| $ touch .ocamlformat | ||
|
|
||
| In the above project, two modules have their implementation generated: | ||
| - [Other_gen]'s implementation is generated by a rule stanza | ||
| - [Parser_raw]'s implementation is genrated by menhir stanza | ||
|
|
||
| Formatting the codebase should not trigger the generation of missing modules | ||
| $ dune build @fmt | ||
|
|
||
| As expected, Dune did not try to generate the missing implem for [Parser_raw] | ||
| $ dune_cmd exists _build/default/parser_raw.ml | ||
| false | ||
|
|
||
| As expected, Dune did not try to generate the missing implem for [Other_gen] | ||
| $ dune_cmd exists _build/default/other_gen.ml | ||
| false | ||
|
|
||
| $ dune clean | ||
|
|
||
| Now we add [mli] files for the two modules whose implementation is generated: | ||
|
|
||
| $ touch other_gen.mli | ||
| $ touch parser_raw.mli | ||
|
|
||
| We format again. | ||
| $ dune build @fmt | ||
| Warning: one state end-of-stream conflict was arbitrarily resolved. | ||
| File "parser_raw.mly", line 5, characters 4-7: | ||
| Warning: production prog -> EOL is never reduced. | ||
| Warning: in total, 1 production is never reduced. | ||
| File "parser_raw.mli", line 1, characters 0-0: | ||
| Error: Files _build/default/parser_raw.mli and | ||
| _build/default/.formatted/parser_raw.mli differ. | ||
| [1] | ||
|
|
||
| FIXME: unexpectedly, Dune generated the missing parser | ||
| $ dune_cmd exists _build/default/parser_raw.ml | ||
| true | ||
|
|
||
| As expected, Dune did not try to generate the missing implem for [Other_gen] | ||
| $ dune_cmd exists _build/default/other_gen.ml | ||
| false | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.