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

rebindable-clash-warning-fix : correct warning logic #245

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@shayne-fletcher-da
Copy link
Contributor

shayne-fletcher-da commented Dec 24, 2018

A warning of the form "The fallible pattern ... is used together with -XRebindableSyntax. If this is intentional compile with -Wno-missing-monad-fail-instances" is colloquially called a "rebindable clash" warning.

If the rebindable syntax and monad fail desugaring language extensions are enabled, rebindable clash warnings are issued irrespective of the setting of -Wmissing-monad-fail-instances flag. This patch fixes that.

We expect:

  • If rebindable syntax is enabled and monad fail desugaring is enabled and the flag -Wmissing-monadfail-instances is in effect, rebindable clash warnings should be displayed;
  • If rebindable syntax is enabled and monad fail desugaring is enabled and the flag -Wno-missing-monadfail-instances is in effect, rebindable clash warnings should not be displayed;
  • If rebindable syntax is enabled and monad fail desugaring is not enabled then rebindable clash warnings should not be displayed.
  • If rebindable syntax is not enabled then rebindable clash warnings should not be displayed.

Put another way, we expect rebindable clash warnings iff rebindable syntax is enabled and monad fail desugaring is enabled and the -Wmissing-monad-fail-instances flag is set.

Program for testing:

{-# LANGUAGE RebindableSyntax, MonadFailDesugaring #-}
{-# OPTIONS_GHC -Wno-missing-monadfail-instances #-}

module Main where

import Prelude

catMaybes xs = do
    Just x <- xs
    return x

main = print 1
@ndmitchell

This comment has been minimized.

Copy link
Contributor

ndmitchell commented Dec 26, 2018

To be clear, before this patch there was no way to suppress this warning. Thanks Shayne for fixing that!

The other alternative, given that the warning is pretty useless (in my opinion) and was never correct (so unlikely anyone hit it usefully and no one could have correctly followed its advice) would be to remove the warning from this branch regardless and simplify the code. However, this patch goes in the right direction anyway.

@shayne-fletcher-da

This comment has been minimized.

Copy link
Contributor

shayne-fletcher-da commented Dec 27, 2018

Replacing this PR with merge request https://gitlab.haskell.org/ghc/ghc/merge_requests/46 on gitlab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment