Commit 92db10bc authored by Ben Gamari's avatar Ben Gamari 🐢

testsuite: Deduplicate source in wcompat-warnings test

parent 8a05836a
{-# LANGUAGE NoMonadFailDesugaring #-}
module WCompatWarningsOnOff where
import qualified Data.Semigroup as Semi
monadFail :: Monad m => m a
monadFail = do
Just _ <- undefined
undefined
(<>) = undefined -- Semigroup warnings
-- -fwarn-noncanonical-monoid-instances
newtype S = S Int
instance Semi.Semigroup S where
(<>) = mappend
instance Monoid S where
S a `mappend` S b = S (a+b)
mempty = S 0
-- Test purpose:
-- Ensure that not using -Wcompat does not enable its warnings
{-# LANGUAGE NoMonadFailDesugaring #-}
-- {-# OPTIONS_GHC -Wcompat #-}
-- {-# OPTIONS_GHC -Wno-compat #-}
module WCompatWarningsNotOn where
import qualified Data.Semigroup as Semi
monadFail :: Monad m => m a
monadFail = do
Just _ <- undefined
undefined
(<>) = undefined -- Semigroup warnings
-- -fwarn-noncanonical-monoid-instances
newtype S = S Int
instance Semi.Semigroup S where
(<>) = mappend
instance Monoid S where
S a `mappend` S b = S (a+b)
mempty = S 0
{-# LANGUAGE CPP #-}
#include "Template.hs"
-- Test purpose:
-- Ensure that using -Wno-compat does not switch on warnings
{-# LANGUAGE NoMonadFailDesugaring #-}
-- {-# OPTIONS_GHC -Wcompat #-}
{-# OPTIONS_GHC -Wno-compat #-}
module WCompatWarningsOff where
import qualified Data.Semigroup as Semi
monadFail :: Monad m => m a
monadFail = do
Just _ <- undefined
undefined
(<>) = undefined -- Semigroup warnings
-- -fwarn-noncanonical-monoid-instances
newtype S = S Int
instance Semi.Semigroup S where
(<>) = mappend
instance Monoid S where
S a `mappend` S b = S (a+b)
mempty = S 0
{-# OPTIONS_GHC -Wno-compat #-}
{-# LANGUAGE CPP #-}
#include "Template.hs"
-- Test purpose:
-- Ensure that -Wcompat switches on the right warnings
{-# LANGUAGE NoMonadFailDesugaring #-}
{-# OPTIONS_GHC -Wcompat #-}
-- {-# OPTIONS_GHC -Wno-compat #-}
module WCompatWarningsOn where
import qualified Data.Semigroup as Semi
monadFail :: Monad m => m a
monadFail = do
Just _ <- undefined
undefined
(<>) = undefined -- Semigroup warnings
-- -fwarn-noncanonical-monoid-instances
newtype S = S Int
instance Semi.Semigroup S where
(<>) = mappend
instance Monoid S where
S a `mappend` S b = S (a+b)
mempty = S 0
{-# OPTIONS_GHC -Wcompat #-}
{-# LANGUAGE CPP #-}
#include "Template.hs"
WCompatWarningsOn.hs:13:5: warning: [-Wmissing-monadfail-instances (in -Wcompat)]
Template.hs:9:5: warning: [-Wmissing-monadfail-instances (in -Wcompat)]
• Could not deduce (Control.Monad.Fail.MonadFail m)
arising from the failable pattern ‘Just _’
(this will become an error in a future GHC release)
from the context: Monad m
bound by the type signature for:
monadFail :: forall (m :: * -> *) a. Monad m => m a
at WCompatWarningsOn.hs:11:1-27
at Template.hs:7:1-27
Possible fix:
add (Control.Monad.Fail.MonadFail m) to the context of
the type signature for:
......@@ -20,16 +20,16 @@ WCompatWarningsOn.hs:13:5: warning: [-Wmissing-monadfail-instances (in -Wcompat)
= do Just _ <- undefined
undefined
WCompatWarningsOn.hs:16:1: warning: [-Wsemigroup (in -Wcompat)]
Template.hs:12:1: warning: [-Wsemigroup (in -Wcompat)]
Local definition of ‘<>’ clashes with a future Prelude name.
This will become an error in a future release.
WCompatWarningsOn.hs:22:3: warning: [-Wnoncanonical-monoid-instances (in -Wcompat)]
Template.hs:18:3: warning: [-Wnoncanonical-monoid-instances (in -Wcompat)]
Noncanonical ‘(<>) = mappend’ definition detected
in the instance declaration for ‘Semigroup S’.
Move definition from ‘mappend’ to ‘(<>)’
WCompatWarningsOn.hs:25:3: warning: [-Wnoncanonical-monoid-instances (in -Wcompat)]
Template.hs:21:3: warning: [-Wnoncanonical-monoid-instances (in -Wcompat)]
Noncanonical ‘mappend’ definition detected
in the instance declaration for ‘Monoid S’.
Define as ‘mappend = (<>)’
-- Test purpose:
-- Ensure that -Wno-compat disables a previously set -Wcompat
{-# LANGUAGE NoMonadFailDesugaring #-}
{-# OPTIONS_GHC -Wcompat #-}
{-# OPTIONS_GHC -Wno-compat #-}
module WCompatWarningsOnOff where
import qualified Data.Semigroup as Semi
monadFail :: Monad m => m a
monadFail = do
Just _ <- undefined
undefined
(<>) = undefined -- Semigroup warnings
-- -fwarn-noncanonical-monoid-instances
newtype S = S Int
instance Semi.Semigroup S where
(<>) = mappend
instance Monoid S where
S a `mappend` S b = S (a+b)
mempty = S 0
{-# OPTIONS_GHC -Wcompat -Wno-compat #-}
{-# LANGUAGE CPP #-}
#include "Template.hs"
test('WCompatWarningsOn', normal, compile, [''])
test('WCompatWarningsOff', normal, compile, [''])
test('WCompatWarningsNotOn', normal, compile, [''])
test('WCompatWarningsOnOff', normal, compile, [''])
# N.B. the source files are all stubs; edit Template.hs
test('WCompatWarningsOn', extra_files(['Template.hs']), compile, [''])
test('WCompatWarningsOff', extra_files(['Template.hs']), compile, [''])
test('WCompatWarningsNotOn', extra_files(['Template.hs']), compile, [''])
test('WCompatWarningsOnOff', extra_files(['Template.hs']), compile, [''])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment