[GHC] #14093: GHC.Exe Panic (The 'Impossible' happened)
GHC
ghc-devs at haskell.org
Sun Aug 6 03:44:56 UTC 2017
#14093: GHC.Exe Panic (The 'Impossible' happened)
-------------------------------------+-------------------------------------
Reporter: ColonelTrick | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Unfortunately, I am just learning Haskell, so I do not have the context to
narrow this down to a narrow repro.
Console Output:
PS C:\Haskell> ghc -o creditCard .\CreditCards.hs
[1 of 1] Compiling Main ( CreditCards.hs, Credit
ghc.exe: panic! (the 'impossible' happened)
(GHC version 8.0.2 for x86_64-unknown-mingw32):
initTc: unsolved constraints
WC {wc_insol = [W] n_a1PN :: t_a1PM[tau:1] (CHoleCan: n)}
CreditCards.hs
{{{#!hs
-- Converts a number to digits
toDigits :: Integer -> [Integer]
toDigits n
| n <= 0 = []
| otherwise = n `mod` 10 : toDigits (n `div` 10)
-- Converts a number to digits and then reverses it
toDigitsRev :: Integer -> [Integer]
toDigitsRev n = reverse . toDigits n
-- Doubles every other value
doubleEveryOther :: [Integer] -> [Integer]
doubleEveryOther[] = []
doubleEveryOther ([x:[]]) = [x]
doubleEveryOther (x : y : zs) = x : 2 * y : doubleEveryOther zs
-- Sums the digits of the credit card.
sumDigits :: [Integer] -> [Integer]
sumDigits [] = 0
sumDigits (x:xs)
| x < 10 = x + sumDigits xs
| otherwise = (x `mod` 10) + (x `div` 10) + sumDigits xs
--- Inidicates whether the credit card is valid.
validate :: [Integer] -> Bool
validate x = (sumDigits (doubleEveryOther (toDigitsRev n)) `mod` 10) == 0
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14093>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list