diff options
author | Adam Gundry <adam@well-typed.com> | 2021-02-04 22:13:21 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-03-10 10:33:36 -0500 |
commit | 5581e7b4c3ab6aa2bb7cca6ed917ed40ad3ed423 (patch) | |
tree | ea2ce6a75ce1c3f3c506973c9405ecf4871cc22f /testsuite/tests/overloadedrecflds | |
parent | d095954bc9dfcee9f3094bc4994b3a69df8f409d (diff) | |
download | haskell-5581e7b4c3ab6aa2bb7cca6ed917ed40ad3ed423.tar.gz |
Simplify shadowing of DuplicateRecordFields in GHCi (fixes #19314)
Previously, defining fields with DuplicateRecordFields in GHCi lead to
strange shadowing behaviour, whereby fields would (accidentally) not
shadow other fields. This simplifies things so that fields are shadowed
in the same way whether or not DuplicateRecordFields is enabled.
Diffstat (limited to 'testsuite/tests/overloadedrecflds')
4 files changed, 33 insertions, 22 deletions
diff --git a/testsuite/tests/overloadedrecflds/ghci/T19314.script b/testsuite/tests/overloadedrecflds/ghci/T19314.script new file mode 100644 index 0000000000..793841fbac --- /dev/null +++ b/testsuite/tests/overloadedrecflds/ghci/T19314.script @@ -0,0 +1,12 @@ +:set -XPatternSynonyms +pattern P{w} = [w] +:t w +:set -XDuplicateRecordFields +pattern Q{x} = [x] +:t x +:set -XNoFieldSelectors +pattern R{y} = [y] +:t y +:set -XNoDuplicateRecordFields +pattern S{z} = [z] +:t z diff --git a/testsuite/tests/overloadedrecflds/ghci/T19314.stdout b/testsuite/tests/overloadedrecflds/ghci/T19314.stdout new file mode 100644 index 0000000000..4e09a8a476 --- /dev/null +++ b/testsuite/tests/overloadedrecflds/ghci/T19314.stdout @@ -0,0 +1,12 @@ +w :: [a] -> a +x :: [a] -> a + +<interactive>:1:1: + • Variable not in scope: y + • NB: ‘y’ is a field selector + that has been suppressed by NoFieldSelectors + +<interactive>:1:1: + • Variable not in scope: z + • NB: ‘z’ is a field selector + that has been suppressed by NoFieldSelectors diff --git a/testsuite/tests/overloadedrecflds/ghci/all.T b/testsuite/tests/overloadedrecflds/ghci/all.T index f0d2544c0e..17f4f82ff5 100644 --- a/testsuite/tests/overloadedrecflds/ghci/all.T +++ b/testsuite/tests/overloadedrecflds/ghci/all.T @@ -3,3 +3,4 @@ test('overloadedlabelsghci01', combined_output, ghci_script, ['overloadedlabelsg test('T13438', [expect_broken(13438), combined_output], ghci_script, ['T13438.script']) test('GHCiDRF', [extra_files(['GHCiDRF.hs']), combined_output], ghci_script, ['GHCiDRF.script']) test('T19322', combined_output, ghci_script, ['T19322.script']) +test('T19314', combined_output, ghci_script, ['T19314.script']) diff --git a/testsuite/tests/overloadedrecflds/ghci/duplicaterecfldsghci01.stdout b/testsuite/tests/overloadedrecflds/ghci/duplicaterecfldsghci01.stdout index ff758c18bb..c7550d36e2 100644 --- a/testsuite/tests/overloadedrecflds/ghci/duplicaterecfldsghci01.stdout +++ b/testsuite/tests/overloadedrecflds/ghci/duplicaterecfldsghci01.stdout @@ -1,29 +1,15 @@ True -type S :: * -data S = MkS {Ghci1.foo :: Int} - -- Defined at <interactive>:3:16 - type T :: * -> * -data T a = MkT {Ghci2.foo :: Bool, ...} +data T a = MkT {foo :: Bool, ...} -- Defined at <interactive>:4:18 +foo :: T a -> Bool -<interactive>:1:1: error: - Ambiguous occurrence ‘foo’ - It could refer to - either the field ‘foo’, defined at <interactive>:3:16 - or the field ‘foo’, defined at <interactive>:4:18 - -<interactive>:9:1: error: - Ambiguous occurrence ‘foo’ - It could refer to - either the field ‘foo’, defined at <interactive>:3:16 - or the field ‘foo’, defined at <interactive>:4:18 +<interactive>:9:6: error: + • Couldn't match expected type ‘T a0’ with actual type ‘S’ + • In the first argument of ‘foo’, namely ‘(MkS 42)’ + In the expression: foo (MkS 42) + In an equation for ‘it’: it = foo (MkS 42) True - -<interactive>:1:1: error: - Ambiguous occurrence ‘foo’ - It could refer to - either the field ‘foo’, defined at <interactive>:3:16 - or the field ‘foo’, defined at <interactive>:4:18 +foo :: T a -> Bool foo :: U -> Int 42 |