diff options
author | Andreas Klebinger <klebinger.andreas@gmx.at> | 2021-01-20 16:24:14 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-02-27 08:00:08 -0500 |
commit | 60bf4d7ca59e333db6349948b8140651d0190004 (patch) | |
tree | 706809fce670feb8b5799bebbf95c379593ec2f3 /testsuite/tests/pmcheck | |
parent | 966a768e9b99e72c9d98a1c971427044888d6de9 (diff) | |
download | haskell-60bf4d7ca59e333db6349948b8140651d0190004.tar.gz |
Fix typechecking time bug for large rationals (#15646)
When desugaring large overloaded literals we now avoid
computing the `Rational` value. Instead prefering to
store the significant and exponent as given where
reasonable and possible.
See Note [FractionalLit representation] for details.
Diffstat (limited to 'testsuite/tests/pmcheck')
-rw-r--r-- | testsuite/tests/pmcheck/should_compile/T19384.hs | 34 | ||||
-rw-r--r-- | testsuite/tests/pmcheck/should_compile/all.T | 5 |
2 files changed, 39 insertions, 0 deletions
diff --git a/testsuite/tests/pmcheck/should_compile/T19384.hs b/testsuite/tests/pmcheck/should_compile/T19384.hs new file mode 100644 index 0000000000..1cecffa8ad --- /dev/null +++ b/testsuite/tests/pmcheck/should_compile/T19384.hs @@ -0,0 +1,34 @@ +{-# OPTIONS_GHC -Wno-missing-methods #-} + +-- Pattern match checking is broken for overloaded rationals currently. + +module T15646a where + + +foo_small :: () +foo_small = case 2e2 :: Rational of + 2e1 -> () -- redundant + 2e2 -> () + +-- Large exponents are handled differently so we have an extra check. +foo :: () +foo = case 2e102 :: Rational of + 2e101 -> () -- redundant + 2e102 -> () + +-- Any literal of type T will desugar to the same value MkT. +-- Eg. (1.0 :: T) == MkT +data T = MkT deriving Eq +instance Num T where +instance Fractional T where + fromRational _ = MkT + +bar :: () +bar = case 2e102 :: T of + 2e101 -> () -- not redundant, pattern evaluates to MkT + 2e102 -> () -- redundant, pattern also evaluates to MkT + +baz :: () +baz = case 2e1 :: T of + 2e1 -> () -- not redundant, pattern evaluates to MkT + 2e2 -> () -- redundant, pattern also evaluates to MkT diff --git a/testsuite/tests/pmcheck/should_compile/all.T b/testsuite/tests/pmcheck/should_compile/all.T index 40b59b2fd3..b922696fae 100644 --- a/testsuite/tests/pmcheck/should_compile/all.T +++ b/testsuite/tests/pmcheck/should_compile/all.T @@ -252,3 +252,8 @@ test('EmptyCase009', [], compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('EmptyCase010', [], compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) + +# Overloaded patterns and rational pattern matching being broken. +test('T19384', + expect_broken(19384), + compile, ['']) |