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 #3574 and support resolve in explicit records #3750

Merged
merged 17 commits into from
Aug 24, 2023

Conversation

joyfulmantis
Copy link
Collaborator

@joyfulmantis joyfulmantis commented Aug 8, 2023

This PR fixes #3574 in addition to implementing resolve for explicit record fields.

@michaelpj
Copy link
Collaborator

Obsoletes #3579, right?

@joyfulmantis
Copy link
Collaborator Author

Obsoletes #3579, right?

Yes. That PR only fixed part of the bug, and Berk didn't have time to finish it, so I'm expanding on his changes to completely fix the bug in addition to providing resolve support here.

@joyfulmantis joyfulmantis changed the title WIP Fix #3574 and support resolve in explicit records Fix #3574 and support resolve in explicit records Aug 9, 2023
@joyfulmantis joyfulmantis marked this pull request as ready for review August 9, 2023 15:39
@joyfulmantis joyfulmantis requested review from michaelpj and ozkutuk and removed request for pepeiborra and ozkutuk August 9, 2023 15:39
@joyfulmantis joyfulmantis enabled auto-merge (squash) August 9, 2023 15:44
Copy link
Collaborator

@ozkutuk ozkutuk left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. I had a brief look and it all looks good to me. I just have a few questions:

  1. I couldn't understand what this "resolve" business about. Admittedly I have been away from HLS codebase for some time. Is that something recently introduced by the LSP spec? Can you point me to a resource (I tried to find the PR that introduced it to HLS but failed to do so) so that I can figure out what is going on with these changes?
  2. I realized that you have removed the CollectNames rule and embedded the functionality directly into the rule of the plugin itself. Is there a particular reason to do so? I think the idea with writing it as a separate rule in the first place was that it was a pretty general rule that could be used by other plugins, and in that case the results could be shared between the plugins by means of using a shared rule.

@joyfulmantis
Copy link
Collaborator Author

1. I couldn't understand what this "resolve" business about. Admittedly I have been away from HLS codebase for some time. Is that something recently introduced by the LSP spec? Can you point me to a resource (I tried to find the PR that introduced it to HLS but failed to do so) so that I can figure out what is going on with these changes?

Yes, that's functionality since 3.16 https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeAction_resolve . Theoretically, it allows us to delay some computations until we actually need it. (For example, we only render the text edit now at the last moment right before the client applies it)

2. I realized that you have removed the `CollectNames` rule and embedded the functionality directly into the rule of the plugin itself. Is there a particular reason to do so? I think the idea with writing it as a separate rule in the first place was that it was a pretty general rule that could be used by other plugins, and in that case the results could be shared between the plugins by means of using a shared rule.

I did that to simplify the code, as it's currently not used by anyone else. I don't feel strongly about that, and am happy to add it back in, although it might be more discoverable if moved to ghcide.

@michaelpj
Copy link
Collaborator

It does sound like it would be good to write an overview of how resolve works and when you might want to use it. Maybe in the module haddock for the Resolve module in hls-plugin-utils?

@joyfulmantis
Copy link
Collaborator Author

It does sound like it would be good to write an overview of how resolve works and when you might want to use it. Maybe in the module haddock for the Resolve module in hls-plugin-utils?

Done

Copy link
Collaborator

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

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

LGTM

@michaelpj michaelpj added the merge me Label to trigger pull request merge label Aug 22, 2023
@michaelpj
Copy link
Collaborator

I would normally think this was just the tests being weird, but two of the windows jobs are hanging for an hour on... the explicit record fields test. Could we somehow have ended up with a case where we'll hang? I would expect lsp-test to time out if things take too long, so I'm not sure how this could happen.

@michaelpj
Copy link
Collaborator

I canceled it, and indeed it was hanging in the new HsExpanded tests!

@joyfulmantis
Copy link
Collaborator Author

Crazy because it's a windows only problem too. The Linux tests for those versions fail very quickly as they should

@joyfulmantis
Copy link
Collaborator Author

Trying to set up a Windows machine will be a headache, and there is nothing obvious about why they would hang on Windows. I'll try to run the tests again with debug to see if I can spot the issue, otherwise, I am tempted to just put in CPP to avoid the test on Windows (versus the expected failure that it is now).

@michaelpj
Copy link
Collaborator

I am tempted to just put in CPP to avoid the test on Windows (versus the expected failure that it is now).

I'd be fine with that if it was just a failure, but if it's a hang, that can be really bad if people hit it. Not sure what to do :( Can we split out the HsExpanded fix into another PR for now?

@joyfulmantis
Copy link
Collaborator Author

I am tempted to just put in CPP to avoid the test on Windows (versus the expected failure that it is now).

I'd be fine with that if it was just a failure, but if it's a hang, that can be really bad if people hit it. Not sure what to do :( Can we split out the HsExpanded fix into another PR for now?

Yes, that won't be too hard. However, I am pretty sure this is a lsp-test issue. The test file that's failing, in this case, is one that uses GHC's overloaded-record-dot language extension and thus does not compile on GHC versions less than 9.2. Since it doesn't compile, then that means that none of the rules or methods provided by the plugin would end up getting successfully executed. (Hence highly likely to be a lsp-test issue)

@michaelpj
Copy link
Collaborator

Hmm. Let's see if it fails again.

@joyfulmantis
Copy link
Collaborator Author

Hmm. Let's see if it fails again.

The debug option doesn't turn on any lsp-test debug flags, so I bet it's gonna hang again without telling us anything useful.

@michaelpj
Copy link
Collaborator

Okay, now one of the windows jobs has an unexpected success for the HsExpanded case?

@joyfulmantis
Copy link
Collaborator Author

Okay, now one of the windows jobs has an unexpected success for the HsExpanded case?

Previously I was using a file that uses the overloaded record dot extension to generate the HsExpanded ast, however now I have switched to using if-then-else with rebindable syntax, which I believe is what HsExpanded was first used for. However, even though as of 9.0 they switched if-then-else when rebindable syntax is on to being compiled down to HsExpanded, it previously was still valid syntax (hence the unexpected success).

@michaelpj
Copy link
Collaborator

Still has a flags failure I think.

@mergify mergify bot merged commit 90d71ce into haskell:master Aug 24, 2023
44 checks passed
@fendor fendor mentioned this pull request Aug 25, 2023
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple code action for (at least) explicit record fields
3 participants