Skip to content

Fix #3095: disabling default flags in the cradle is not propagated to hlint properly #3096

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

Closed
wants to merge 6 commits into from

Conversation

lf-
Copy link
Contributor

@lf- lf- commented Aug 12, 2022

There is a lot of detail of the exact issue in #3095.

I assume that all the flags that are not enabled are disabled (the default flags have already been applied at this point; so this is probably actually true).

It seems to fix the issue but it is kind of a hack.

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.

So I think the problem is that hlint enables lots of extensions by default in order to maximise its chances of success when used from the command line.

But in our setting, where we know with full precision the set of extensions that need to be enabled for parsing, this is completely unnecessary.

Have you considered telling hlint not to enable any extensions by default? There should be some config for that.

Comment on lines 336 to 337
-- XXX: we just assume that all not-enabled flags are disabled. this is
-- Kinda Sketchy!
Copy link
Collaborator

@pepeiborra pepeiborra Aug 12, 2022

Choose a reason for hiding this comment

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

Can you extend the comment to clarify why we need to assume? Maybe reference the GHC MR with the fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done :)

@lf-
Copy link
Contributor Author

lf- commented Aug 12, 2022

It seems that we would have to hack up hlint upstream to achieve that. Currently there is no way of passing "exactly these flags" into parseModuleEx, and there does not seem to me to be any obvious deeper entry point into hlint.

The bug on the hlint side is that lang_set sets the default flags for the language, absent any explicit enable/disables. So the only way to currently get hlint to get the right flags is to exhaustively force all of them to the known values, as we don't have a disables list. (besides using the Show OnOff instance which is kind of bad but might actually be cleaner nope that doesn't work because there's no Read instance and the code gets quite ugly quite fast)

We aren't hitting the "many default extensions" trouble, because we wholesale replace the enabledExtensions.

https://github.com/ndmitchell/hlint/blob/c0e77b59adb75d2b043a6f41f9a204cd7d4b42ef/src/GHC/All.hs#L173-L183

@lf-

This comment was marked as outdated.

@lf- lf- force-pushed the hlint-flags-bug branch from 8f7bd94 to 85735c1 Compare August 12, 2022 20:11
@lf- lf- force-pushed the hlint-flags-bug branch from 939b5e8 to c8b690a Compare August 12, 2022 21:39
@pepeiborra
Copy link
Collaborator

pepeiborra commented Aug 13, 2022

@lf-
Copy link
Contributor Author

lf- commented Aug 13, 2022

Yeah, it's odd. I'll look at it on Monday.

@lf- lf- closed this Nov 18, 2022
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.

2 participants