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

Fix top level extensions #2693

Merged
merged 19 commits into from
Mar 18, 2023
Merged

Conversation

davesnx
Copy link
Member

@davesnx davesnx commented Mar 6, 2023

While migrating to Reason 3.8.2 (and above) found a bug when printing extensions. It might be hidden a long time ago since most extensions aren't top-level.

refmt_test/extensions.t/run.t Outdated Show resolved Hide resolved
let last = match (List.rev structureItems) with | last::_ -> last | [] -> assert false in
let loc_start = first.pstr_loc.loc_start in
let loc_end = last.pstr_loc.loc_end in
let items =
groupAndPrint
~xf:self#structure_item
~xf:self#top_level_structure_item
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks fishy.

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably a bad name, but the logic is to check for a specific combination of AST such as: structure -> structure_item -> Pexp_extension

@davesnx davesnx marked this pull request as ready for review March 7, 2023 09:00
@@ -348,7 +348,7 @@ let () = {
something_else();
};

[%bs.raw x => x];
Copy link
Member

Choose a reason for hiding this comment

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

don't we also accept this form? I think it should keep being tested.

Copy link
Member Author

Choose a reason for hiding this comment

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

Pushed back the test case, we do support them.

Copy link
Member

Choose a reason for hiding this comment

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

It's still removed. did you forget to push?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added all of the cases in the cram tests. Let me add them in the formatTest as well

method structure structureItems =
(* We don't have any way to know if an extension is placed at the top level by the parsetree
Copy link
Member

Choose a reason for hiding this comment

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

I thought we supported extensions at the toplevel with %, and that %%bs.raw was specifically a bucklescript thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is a BuckleScript thing, but we support both cases. Would be a nice idea to unify all of these cases with Melange. %bs.raw -> bs.raw_js_expr and %%bs.raw -> bs.raw_js or something like this.

Copy link
Member

Choose a reason for hiding this comment

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

I don't get what needs to be unified?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could avoid having % and %% at the same time and support only %

…el-extensions

* 'master' of github.com:/reasonml/reason:
  Install before importing deps
  Update package json and install esy normally
  Re-arrange esy install
  Reduce install esy time
  Use master branch instead of main
  Ignore _export from esy
  Rename refmt_test to test
  Add esy-ci and opam-ci
  Remove jbuild-ignore
Copy link
Member

@anmonteiro anmonteiro left a comment

Choose a reason for hiding this comment

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

This needs a changelog entry in HISTORY.md. Then please "squash and merge" it.

@davesnx davesnx merged commit c77cf2d into reasonml:master Mar 18, 2023
davesnx added a commit to davesnx/reason that referenced this pull request Mar 18, 2023
…mat-type-tests-to-cram

* 'master' of github.com:/reasonml/reason:
  Fix top level extensions (reasonml#2693)
  Install before importing deps
  Update package json and install esy normally
  Re-arrange esy install
  Reduce install esy time
  Use master branch instead of main
  Ignore _export from esy
  Rename refmt_test to test
  Add esy-ci and opam-ci
  Remove jbuild-ignore
SanderSpies added a commit to SanderSpies/reason that referenced this pull request Apr 18, 2023
* master: (38 commits)
  chore: remove old BS_NO_COMPILER_PATCH flag (reasonml#2710)
  Improve printing of modules types with one line inside (reasonml#2709)
  generate opam files with dune (reasonml#2704)
  Fix version on refmt (reasonml#2701)
  Drop the result dependency (reasonml#2703)
  Remove old CI and test.sh (reasonml#2705)
  Migrate tests to cram suite (reasonml#2694)
  Make sure win doesnt break when importing (reasonml#2700)
  Fix top level extensions (reasonml#2693)
  Install before importing deps
  Update package json and install esy normally
  Re-arrange esy install
  Reduce install esy time
  Use master branch instead of main
  Ignore _export from esy
  Rename refmt_test to test
  Add esy-ci and opam-ci
  Remove jbuild-ignore
  chore: update nix flake (reasonml#2692)
  chore(readme): clarify 3.9 is unreleased
  ...
SanderSpies added a commit to SanderSpies/reason that referenced this pull request Apr 18, 2023
* master: (38 commits)
  chore: remove old BS_NO_COMPILER_PATCH flag (reasonml#2710)
  Improve printing of modules types with one line inside (reasonml#2709)
  generate opam files with dune (reasonml#2704)
  Fix version on refmt (reasonml#2701)
  Drop the result dependency (reasonml#2703)
  Remove old CI and test.sh (reasonml#2705)
  Migrate tests to cram suite (reasonml#2694)
  Make sure win doesnt break when importing (reasonml#2700)
  Fix top level extensions (reasonml#2693)
  Install before importing deps
  Update package json and install esy normally
  Re-arrange esy install
  Reduce install esy time
  Use master branch instead of main
  Ignore _export from esy
  Rename refmt_test to test
  Add esy-ci and opam-ci
  Remove jbuild-ignore
  chore: update nix flake (reasonml#2692)
  chore(readme): clarify 3.9 is unreleased
  ...
SanderSpies added a commit to SanderSpies/reason that referenced this pull request May 4, 2023
* master:
  fix: binary parser (reasonml#2713)
  Improve functor printing. (reasonml#2683)
  chore: remove old BS_NO_COMPILER_PATCH flag (reasonml#2710)
  Improve printing of modules types with one line inside (reasonml#2709)
  generate opam files with dune (reasonml#2704)
  Fix version on refmt (reasonml#2701)
  Drop the result dependency (reasonml#2703)
  Remove old CI and test.sh (reasonml#2705)
  Migrate tests to cram suite (reasonml#2694)
  Make sure win doesnt break when importing (reasonml#2700)
  Fix top level extensions (reasonml#2693)
  Install before importing deps
  Update package json and install esy normally
  Re-arrange esy install
  Reduce install esy time
  Use master branch instead of main
  Ignore _export from esy
  Rename refmt_test to test
  Add esy-ci and opam-ci
  Remove jbuild-ignore
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.

None yet

3 participants