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

Restore ability to run source plugins #3309

Merged
merged 11 commits into from
Dec 20, 2022

Conversation

JakobBruenker
Copy link
Contributor

@JakobBruenker JakobBruenker commented Oct 30, 2022

Since ghc 9.0, plugins are stored in the HscEnv, not in the DynFlags. This caused HLS not to run source plugins anymore. This commit fixes that.

Fixes #3299.

It also fixes one of the two problems mentioned in #2779, which is that the plugin wasn't running in HLS. It does not fix the problem where HLS shows the wrong location for the error message described in that issue.

If I should add a test it would be helpful to know which test-data directory it should go into, and which files I have to look at to make the test run.

Since ghc 9.0, plugins are stored in the HscEnv, not in the DynFlags.
This caused HLS not to run source plugins anymore. This commit fixes
that.

Fixes haskell#3299.
@pepeiborra
Copy link
Collaborator

Thank you! This is great stuff.

If I should add a test it would be helpful to know which test-data directory it should go into, and which files I have to look at to make the test run.

The right place for a test would be the ghcide test suite. You can take inspiration on the existing plugin tests, as well to reenable the ones that are disabled for GHC 9.x

Copy link
Collaborator

@pepeiborra pepeiborra left a comment

Choose a reason for hiding this comment

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

Changes requested: we need tests to avoid breaking this stuff in the future

@fendor
Copy link
Collaborator

fendor commented Nov 1, 2022

You can enable the test here:

ignoreForGHC92Plus "blocked on ghc-typelits-natnormalise" $

Might be broken for windows.

In 9.4, the ability for parser source plugins to access and manipulate
non-fatal parse errors was added:
https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.4#parser-plugins-have-a-different-type

HLS always threw an error in this situation without running the plugins
though. This commit fixes that.
@JakobBruenker
Copy link
Contributor Author

Before I address your comments: I noticed that the ability for parser plugins to change error messages, introduced in 9.4, wasn't supported by HLS. This new commit fixes that. I haven't had time yet to test it with every supported GHC version, however.

I'm still seeing an expectJust crash (here) when running HLS on one of my tests cases, so I'll have to figure out why that is happening still.

@m4dc4p
Copy link

m4dc4p commented Nov 16, 2022

I ran cabal test (using latest master) and they all passed. Can we get this merged? I'd really like to have this functionality back.

edit: oops, I was running under GHC 9.0.2. :(

@fendor
Copy link
Collaborator

fendor commented Dec 19, 2022

@JakobBruenker Do you think you have time to push this over the finish line for #3409? If not, I can take a look at it.

EDIT: sorry, couldn't stop myself 🙈

@fendor fendor force-pushed the fix-source-plugins branch from c564332 to 4a44857 Compare December 19, 2022 12:14
@fendor fendor requested a review from pepeiborra December 19, 2022 12:23
Comment on lines +364 to +365
-- Implicit assumption: DynFlags in 'msrModSummary' are the same as
-- the DynFlags in 'msrHscEnv'.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is inaccurate, later in the pipeline, dozens of functions modify the 'DynFlags' from 'msrModSummary'. This comment will be changed to basically telling users to prefer the DynFlags from msrModSummary instead of from this HscEnv. Does this seem sensible?

@wz1000 wz1000 enabled auto-merge (rebase) December 19, 2022 18:37
@wz1000 wz1000 disabled auto-merge December 20, 2022 09:54
@wz1000 wz1000 enabled auto-merge (rebase) December 20, 2022 09:54
@fendor fendor dismissed pepeiborra’s stale review December 20, 2022 13:58

Have been adressed

@wz1000 wz1000 merged commit ff28990 into haskell:master Dec 20, 2022
@JakobBruenker
Copy link
Contributor Author

JakobBruenker commented Dec 20, 2022

@fendor sorry, didn't see your comment yesterday. Sorry to have this let sit idle, I'm happy to see it's done!

@JakobBruenker JakobBruenker deleted the fix-source-plugins branch December 20, 2022 16:30
@fendor
Copy link
Collaborator

fendor commented Dec 20, 2022

@JakobBruenker Dont be sorry, you did a valuable contribution, and I am genuinely thankful for that! I didn't give you any time to react, happy that you are not mad at me for taking over!

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.

HLS ignores GHC plugins
6 participants