diff options
author | sheaf <sam.derbyshire@gmail.com> | 2022-08-25 20:24:19 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-08-26 15:05:23 -0400 |
commit | 4786acf758ef064d3b79593774d1672e294b0afb (patch) | |
tree | 35d46e759acda4015c488cb5a2bec9b8d00cdeba /testsuite/tests | |
parent | 6b47aa1cc87426db4fe7d805af69894de05780ff (diff) | |
download | haskell-4786acf758ef064d3b79593774d1672e294b0afb.tar.gz |
Pmc: consider any 2 dicts of the same type equal
This patch massages the keys used in the `TmOracle` `CoreMap` to ensure
that dictionaries of coherent classes give the same key.
That is, whenever we have an expression we want to insert or lookup in
the `TmOracle` `CoreMap`, we first replace any dictionary
`$dict_abcd :: ct` with a value of the form `error @ct`.
This allows us to common-up view pattern functions with required
constraints whose arguments differed only in the uniques of the
dictionaries they were provided, thus fixing #21662.
This is a rather ad-hoc change to the keys used in the
`TmOracle` `CoreMap`. In the long run, we would probably want to use
a different representation for the keys instead of simply using
`CoreExpr` as-is. This more ambitious plan is outlined in #19272.
Fixes #21662
Updates unix submodule
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/pmcheck/should_compile/T11822.stderr | 8 | ||||
-rw-r--r-- | testsuite/tests/pmcheck/should_compile/T21662.hs | 21 | ||||
-rw-r--r-- | testsuite/tests/pmcheck/should_compile/all.T | 1 |
3 files changed, 22 insertions, 8 deletions
diff --git a/testsuite/tests/pmcheck/should_compile/T11822.stderr b/testsuite/tests/pmcheck/should_compile/T11822.stderr index 7f0aae9aec..d2994b65aa 100644 --- a/testsuite/tests/pmcheck/should_compile/T11822.stderr +++ b/testsuite/tests/pmcheck/should_compile/T11822.stderr @@ -12,11 +12,3 @@ T11822.hs:33:1: warning: [-Wincomplete-patterns (in -Wextra)] _ _ _ (Data.Sequence.Internal.Seq Data.Sequence.Internal.EmptyT) _ _ ... - -T11822.hs:33:1: warning: - Pattern match checker ran into -fmax-pmcheck-models=30 limit, so - • Redundant clauses might not be reported at all - • Redundant clauses might be reported as inaccessible - • Patterns reported as unmatched might actually be matched - Suggested fix: - Increase the limit or resolve the warnings to suppress this message. diff --git a/testsuite/tests/pmcheck/should_compile/T21662.hs b/testsuite/tests/pmcheck/should_compile/T21662.hs new file mode 100644 index 0000000000..1a3ff6cb6e --- /dev/null +++ b/testsuite/tests/pmcheck/should_compile/T21662.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE TypeApplications #-} + +module T21662 where + +import GHC.TypeNats (Nat, KnownNat) + +view_fn :: forall (n :: Nat). KnownNat n => Int -> Bool +view_fn i = i > 0 + +foo :: Int -> Int +foo (view_fn @12 -> True) = 0 +foo (view_fn @12 -> False) = 0 + + -- The point is that the two view pattern functions "view_fn" + -- may get different uniques for the KnownNat 12 dictionary, + -- which leads to a spurious pattern match warning. diff --git a/testsuite/tests/pmcheck/should_compile/all.T b/testsuite/tests/pmcheck/should_compile/all.T index fe63d364f7..6415e83dab 100644 --- a/testsuite/tests/pmcheck/should_compile/all.T +++ b/testsuite/tests/pmcheck/should_compile/all.T @@ -111,6 +111,7 @@ test('CyclicSubst', [], compile, [overlapping_incomplete]) test('CaseOfKnownCon', [], compile, [overlapping_incomplete]) test('TooManyDeltas', [], compile, [overlapping_incomplete+'-fmax-pmcheck-models=0']) test('LongDistanceInfo', [], compile, [overlapping_incomplete]) +test('T21662', [], compile, [overlapping_incomplete]) # Series (inspired) by Luke Maranget |