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

Wingman: Don't clobber where clauses #2184

Merged
merged 4 commits into from Sep 13, 2021

Conversation

isovector
Copy link
Collaborator

@isovector isovector commented Sep 10, 2021

Wingman generates lambdas and case expressions by default. When it thinks it's operating over a top-level hole, it will instead replace the entire match group, by desugaring the lambdas and cases into explicit matches. This works fine unless there's a where attached to the original match group --- in which case it gets clobbered.

This PR prevents the match-group splicing behavior if there's a where attached to the hole. It's not the world's best fix, but it's a quick fix. The bug is pretty destructive so I'd rather get it fixed quickly than perfectly. And it's not clear what a perfect solution would look like here.

Fixes #2183

Copy link
Collaborator

@santiweight santiweight left a comment

Choose a reason for hiding this comment

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

Looks good to me :)

-- It's important that there is no where clause because otherwise it gets
-- clobbered. See #2183 for an example.
--
-- This isn't a perfect check, and produces some ugly code. But it's much much
Copy link
Collaborator

Choose a reason for hiding this comment

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

In what way is this not a perfect check? I don't quite catch your meaning here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I also don't quite understand why this produces ugly code.

@isovector isovector added the merge me Label to trigger pull request merge label Sep 13, 2021
@mergify mergify bot merged commit e1075e8 into haskell:master Sep 13, 2021
jneira added a commit to jneira/haskell-language-server that referenced this pull request Sep 14, 2021
* Extend TopLevelRHS pattern to track the where clause

* Don't case split if there's a where clause

* Add tests

Co-authored-by: Javier Neira <atreyu.bbb@gmail.com>
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.

Wingman removes functions in where clauses during refine hole
3 participants