diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2020-02-06 16:14:25 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-02-08 10:27:23 -0500 |
commit | b6dc319a2d83a8a8c426d0ad6f46d0b8fad41253 (patch) | |
tree | d587f41ca99f515306c59b48b4e2d6f9c0ffb307 /testsuite | |
parent | c95920a6371768276e439811e99f4822571ff4df (diff) | |
download | haskell-b6dc319a2d83a8a8c426d0ad6f46d0b8fad41253.tar.gz |
Add regression test for #12760
The bug seems to be fixed in the meantime, make sure it stays fixed.
Closes #12760
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T12760.hs | 36 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/all.T | 1 |
2 files changed, 37 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T12760.hs b/testsuite/tests/typecheck/should_compile/T12760.hs new file mode 100644 index 0000000000..40db2d500a --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T12760.hs @@ -0,0 +1,36 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving #-} + +module A where + +import Data.List (minimumBy) +import Data.Ord (comparing) + +data A a = A Int + +newtype B = B Double + deriving (Eq,Ord,Num,Real,Fractional,RealFrac,Floating,RealFloat) + +class C a where + _c :: [a] -> D a + +instance C B where + _c = f2 u + +data D x = D [(x,Double)] [ x ] + +u = undefined + +f1 :: RealFloat a => A a -> a -> [a] -> D a +f1 (A a1) m ps0 = D (zip tickvs []) labelvs + where + range _ | m == m = if m==0 then (-1,1) else (m, m) + labelvs = map fromRational $ f3 (fromIntegral a1) (range ps0) + tickvs = map fromRational $ f3 (fromIntegral a1) (head labelvs, head labelvs) + +f2 :: RealFloat a => A a -> [a] -> D a +f2 lap ps = f1 u (minimum ps) ps + +f3 :: RealFloat a => a -> (a,a) -> [Rational] +f3 k rs@(m,_ ) = map ((s*) . fromIntegral) [floor m .. ] + where + s = minimumBy (comparing ((+ k) . realToFrac)) [0] diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 0f61b57faf..215b57d87b 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -693,3 +693,4 @@ test('T15839a', normal, compile, ['']) test('T15839b', normal, compile, ['']) test('T17343', exit_code(1), compile_and_run, ['']) test('T17566', [extra_files(['T17566a.hs'])], makefile_test, []) +test('T12760', unless(compiler_debugged(), skip), compile, ['-O']) |