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

Import disambiguation: Corrects handling of fully-applied and one-sided sectioned operators in qualifying strategy #1294

Merged
merged 5 commits into from
Feb 3, 2021

Conversation

konn
Copy link
Collaborator

@konn konn commented Feb 2, 2021

The current implementation of the import disambiguation (introduced in #1264) always qualifies operators with extra parens.
This can destroy the fully- or partially-applied infix operators, as follows:

op = (++)
fun xs ys = xs ++ ys
funL xs = (++ xs)
funR ys = (ys ++)

op = (Prelude.++) -- As expected
fun xs ys = xs (Prelude.++) ys -- oops!
funL xs = ((Prelude.++) xs)  -- ooops!
funR ys = (ys (Prelude.++)) -- oooops!

This PR just fixes it, inspecting the buffer whether the code in question is already parenthesised or not.

Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

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

lgtm, and good test coverage

@konn konn added the merge me Label to trigger pull request merge label Feb 2, 2021
@berberman
Copy link
Collaborator

If you don't mind, could you unify the filename extension of golden tests data to .hs? It would be better for review and can clarify that our codebase doesn't contain E language source code 😄

@Ailrun Ailrun removed the merge me Label to trigger pull request merge label Feb 2, 2021
@Ailrun
Copy link
Member

Ailrun commented Feb 2, 2021

If you don't mind, could you unify the filename extension of golden tests data to .hs? It would be better for review and can clarify that our codebase doesn't contain E language source code 😄

Yes, especially when the "expected" version is better source, like in this case.

@konn
Copy link
Collaborator Author

konn commented Feb 3, 2021

Ah, I just followed the pattern used in Eval plugin, but, yes, those expected files in eval func-test doesn't have so much long extensions. I now renamed disambiguation-related test files to have .hs extensions. Thank you for your suggestions, @berberman @Ailrun!

@konn konn added the merge me Label to trigger pull request merge label Feb 3, 2021
@berberman
Copy link
Collaborator

Can we remove isSymOcc here?

Did you see my comment? I think it's enough to consider only parensed. If a non-symbolic identifier is parenthesized unnecessarily, the range reported in diagnostic won't include the parenthesis part, i.e. parensed will be False, so I think it doesn't matter if isSymOcc occSym is True. Correct me if I'm wrong :)

@konn konn removed the merge me Label to trigger pull request merge label Feb 3, 2021
@konn
Copy link
Collaborator Author

konn commented Feb 3, 2021

Can we remove isSymOcc here?

Did you see my comment? I think it's enough to consider only parensed. If a non-symbolic identifier is parenthesized unnecessarily, the range reported in diagnostic won't include the parenthesis part, i.e. parensed will be False, so I think it doesn't matter if isSymOcc occSym is True. Correct me if I'm wrong :)

Oops, sorry I overlooked your comment 🙇 I think your suggestion makes sense. Thanks!

@berberman berberman added the merge me Label to trigger pull request merge label Feb 3, 2021
@jneira
Copy link
Member

jneira commented Feb 3, 2021

very happy to see more contributors with the commit bit, congrats and thanks for your great work here 🙂

@mergify mergify bot merged commit 8a91d03 into master Feb 3, 2021
@konn konn deleted the fix-infix-qualif branch February 3, 2021 08:14
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.

4 participants