Opened 14 months ago

Closed 14 months ago

## #14093 closed bug (duplicate)

# GHC.Exe Panic (The 'Impossible' happened)

Reported by: | ColonelTrick | Owned by: | |
---|---|---|---|

Priority: | normal | Milestone: | |

Component: | Compiler | Version: | 8.0.2 |

Keywords: | Cc: | ||

Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |

Type of failure: | None/Unknown | Test Case: | |

Blocked By: | Blocking: | ||

Related Tickets: | #13106 | Differential Rev(s): | |

Wiki Page: |

### Description

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

-- 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

### Change History (1)

### comment:1 Changed 14 months ago by

Related Tickets: | → #13106 |
---|---|

Resolution: | → duplicate |

Status: | new → closed |

Version: | 8.2.1 → 8.0.2 |

**Note:**See TracTickets for help on using tickets.

Thanks for the bug report. This is a duplicate of #13106, which has been fixed in GHC 8.2.1. (On GHC 8.2.1, it would give a proper error that

`n`

is out of scope in the definition of`validate`

.)