diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2019-02-11 09:24:04 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-02-14 02:36:02 -0500 |
commit | 19626218566ea709b5f6f287d3c296b0c4021de2 (patch) | |
tree | d22f486e543a19670be2ae88e8e358f99e1e54fd /testsuite/tests/rename/should_compile | |
parent | 1d9a1d9fb8fe0a1fea2c44c4246f102ff3e1f3a3 (diff) | |
download | haskell-19626218566ea709b5f6f287d3c296b0c4021de2.tar.gz |
Implement -Wredundant-record-wildcards and -Wunused-record-wildcards
-Wredundant-record-wildcards warns when a .. pattern binds no variables.
-Wunused-record-wildcards warns when none of the variables bound by a ..
pattern are used.
These flags are enabled by `-Wall`.
Diffstat (limited to 'testsuite/tests/rename/should_compile')
-rw-r--r-- | testsuite/tests/rename/should_compile/T15957.hs | 21 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/all.T | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/testsuite/tests/rename/should_compile/T15957.hs b/testsuite/tests/rename/should_compile/T15957.hs new file mode 100644 index 0000000000..d684e57495 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T15957.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE NamedFieldPuns #-} +module T15957 where + +data P = P { x :: Int, y :: Int } + +g1 P{..} = x + 3 -- x from .. is used +g2 P{x, ..} = x + y -- y from .. is used, even if it's in a weird style + +old P{..} | x < 5 = 10 + +-- Record wildcards in lets have different scoping rules.. they bring +-- all the identifiers into scope +do_example :: IO Int +do_example = do + let P{..} = P 1 2 + return $ x + y + +let_in_example = + let P{..} = P 1 2 + in x + 4 diff --git a/testsuite/tests/rename/should_compile/all.T b/testsuite/tests/rename/should_compile/all.T index 0c60360e17..4d427de44f 100644 --- a/testsuite/tests/rename/should_compile/all.T +++ b/testsuite/tests/rename/should_compile/all.T @@ -166,3 +166,4 @@ test('T15798a', normal, compile, ['']) test('T15798b', normal, compile, ['']) test('T15798c', normal, compile, ['']) test('T16116a', normal, compile, ['']) +test('T15957', normal, compile, ['-Werror -Wredundant-record-wildcards -Wunused-record-wildcards']) |