diff options
author | Adam Gundry <adam@well-typed.com> | 2021-01-08 19:27:45 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-02-26 16:25:39 -0500 |
commit | 80eda911ef1ea711a9e3e51ad510dfe5a9a09ae9 (patch) | |
tree | aa7e1614c76b5c5c31ca772c8300a115c62e9684 /testsuite | |
parent | 29e7f318209794206033065cdc0874a5afe0ad47 (diff) | |
download | haskell-80eda911ef1ea711a9e3e51ad510dfe5a9a09ae9.tar.gz |
Implement -Wambiguous-fields
Fixes #18966. Adds a new warning -Wambiguous-fields for uses of field selectors
or record updates that will be rejected in the future, when the DuplicateRecordFields
extension is simplified per https://github.com/ghc-proposals/ghc-proposals/pull/366.
Diffstat (limited to 'testsuite')
7 files changed, 52 insertions, 0 deletions
diff --git a/testsuite/tests/backpack/should_compile/T13323.stderr b/testsuite/tests/backpack/should_compile/T13323.stderr index eb49bcbfab..7e637d9dd4 100644 --- a/testsuite/tests/backpack/should_compile/T13323.stderr +++ b/testsuite/tests/backpack/should_compile/T13323.stderr @@ -1,6 +1,11 @@ [1 of 3] Processing p [1 of 2] Compiling A[sig] ( p/A.hsig, nothing ) [2 of 2] Compiling P ( p/P.hs, nothing ) + +T13323.bkp:9:13: warning: [-Wambiguous-fields (in -Wdefault)] + The field ‘foo’ belonging to type A is ambiguous. + This will not be supported by -XDuplicateRecordFields in future releases of GHC. + You can use a qualified import or explicit case analysis to resolve the ambiguity. [2 of 3] Processing q Instantiating q [1 of 1] Compiling A ( q/A.hs, T13323.out/q/A.o ) @@ -10,5 +15,10 @@ Instantiating p[A=q:A] [1 of 2] Compiling A[sig] ( p/A.hsig, T13323.out/p/p-HVmFlcYSefiK5n1aDP1v7x/A.o ) [2 of 2] Compiling P ( p/P.hs, T13323.out/p/p-HVmFlcYSefiK5n1aDP1v7x/P.o ) + +T13323.bkp:9:13: warning: [-Wambiguous-fields (in -Wdefault)] + The field ‘foo’ belonging to type A is ambiguous. + This will not be supported by -XDuplicateRecordFields in future releases of GHC. + You can use a qualified import or explicit case analysis to resolve the ambiguity. [1 of 2] Compiling R ( r/R.hs, T13323.out/r/R.o ) [2 of 2] Instantiating p diff --git a/testsuite/tests/overloadedrecflds/should_fail/DRFUnused.stderr b/testsuite/tests/overloadedrecflds/should_fail/DRFUnused.stderr index a9dbd2cdd5..7e75f5c8c7 100644 --- a/testsuite/tests/overloadedrecflds/should_fail/DRFUnused.stderr +++ b/testsuite/tests/overloadedrecflds/should_fail/DRFUnused.stderr @@ -1,3 +1,8 @@ DRFUnused.hs:10:16: error: [-Wunused-top-binds (in -Wextra, -Wunused-binds), -Werror=unused-top-binds] Defined but not used: ‘foo’ + +DRFUnused.hs:18:5: warning: [-Wambiguous-fields (in -Wdefault)] + The field ‘foo’ belonging to type U is ambiguous. + This will not be supported by -XDuplicateRecordFields in future releases of GHC. + You can use explicit case analysis to resolve the ambiguity. diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr index 3aae5c5061..254931a9bc 100644 --- a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr +++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr @@ -26,3 +26,11 @@ overloadedrecfldsfail06.hs:9:1: error: [-Wunused-imports (in -Wextra), -Werror=u overloadedrecfldsfail06.hs:10:1: error: [-Wunused-imports (in -Wextra), -Werror=unused-imports] The qualified import of ‘U(x), U’ from module ‘OverloadedRecFldsFail06_A’ is redundant + +overloadedrecfldsfail06.hs:15:22: error: [-Wambiguous-fields (in -Wdefault), -Werror=ambiguous-fields] + The record update u {x = True} with type U is ambiguous. + This will not be supported by -XDuplicateRecordFields in future releases of GHC. + +overloadedrecfldsfail06.hs:18:28: error: [-Wambiguous-fields (in -Wdefault), -Werror=ambiguous-fields] + The record update v {P.x = 3} with type V is ambiguous. + This will not be supported by -XDuplicateRecordFields in future releases of GHC. diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr index 0aa41a2962..9599cddcba 100644 --- a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr +++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr @@ -4,3 +4,8 @@ overloadedrecfldsfail11.hs:5:15: error: [-Wdeprecations (in -Wdefault), -Werror=deprecations] In the use of ‘foo’ (imported from OverloadedRecFldsFail11_A): "Warning on a record field" + +overloadedrecfldsfail11.hs:5:15: error: [-Wambiguous-fields (in -Wdefault), -Werror=ambiguous-fields] + The field ‘foo’ belonging to type S is ambiguous. + This will not be supported by -XDuplicateRecordFields in future releases of GHC. + You can use a qualified import or explicit case analysis to resolve the ambiguity. diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.hs b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.hs index 56092b6ce0..270c43e5d4 100644 --- a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.hs +++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.hs @@ -12,4 +12,7 @@ f e = e { foo = 3, bar = 3 } s :: T -> Int s = foo +t :: S -> Bool +t = foo + main = return () diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.stderr b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.stderr index e17c9f8573..fe8ac81ef9 100644 --- a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.stderr +++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.stderr @@ -12,3 +12,13 @@ overloadedrecfldsfail12.hs:10:20: error: [-Wdeprecations (in -Wdefault), -Werror overloadedrecfldsfail12.hs:13:5: error: [-Wdeprecations (in -Wdefault), -Werror=deprecations] In the use of ‘foo’ (imported from OverloadedRecFldsFail12_A): "Deprecated foo" + +overloadedrecfldsfail12.hs:13:5: error: [-Wambiguous-fields (in -Wdefault), -Werror=ambiguous-fields] + The field ‘foo’ belonging to type T is ambiguous. + This will not be supported by -XDuplicateRecordFields in future releases of GHC. + You can use a qualified import or explicit case analysis to resolve the ambiguity. + +overloadedrecfldsfail12.hs:16:5: error: [-Wambiguous-fields (in -Wdefault), -Werror=ambiguous-fields] + The field ‘foo’ belonging to type S is ambiguous. + This will not be supported by -XDuplicateRecordFields in future releases of GHC. + You can use explicit case analysis to resolve the ambiguity. diff --git a/testsuite/tests/rename/should_compile/T11167_ambig.stderr b/testsuite/tests/rename/should_compile/T11167_ambig.stderr new file mode 100644 index 0000000000..5320b42149 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T11167_ambig.stderr @@ -0,0 +1,11 @@ + +T11167_ambig.hs:10:13: warning: [-Wambiguous-fields (in -Wdefault)] + The field ‘runContT’ belonging to type ContT r m a is ambiguous. + This will not be supported by -XDuplicateRecordFields in future releases of GHC. + You can use explicit case analysis to resolve the ambiguity. + +T11167_ambig.hs:17:9: warning: [-Wambiguous-fields (in -Wdefault)] + The field ‘runContT’ belonging to type forall a. + ContT () IO a is ambiguous. + This will not be supported by -XDuplicateRecordFields in future releases of GHC. + You can use explicit case analysis to resolve the ambiguity. |