Opened 3 years ago

Closed 3 years ago

#13467 closed bug (duplicate)

ghc: panic! (the 'impossible' happened), initTc: unsolved constraints

Reported by: jhjonsson 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 (last modified by RyanGlScott)

NB! I'm no expert on the compiler and have not used GHC/GHCi very much. I have istaller the Haskell Platform and then run GHCi from within Aquamacs (emacs) using tthe Haskell mode already available there. I should say that everything worked fine and I could both load and run code. But then this happend when I started with the type Char and the functions ord and chr, so maybe the error has to do with them(?) Please change the subject to something relevant; I really have no clue what has happened here. Just like to help. /Håkan --- This is the error message:

GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Prelude> :load "/Users/hj/Downloads/d7012e-vt17/test.hs"
[1 of 1] Compiling Main             ( /Users/hj/Downloads/d7012e-vt17/test.hs, interpreted )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.2 for x86_64-apple-darwin):
	initTc: unsolved constraints
  WC {wc_insol = [W] –_a2n2 :: t_a2n1[tau:1] (CHoleCan: –)}

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

> 

---

This is my Haskell code (putting together examples for a first lecture on declarative languages/functional languages):

module Main (main) where
import Data.Char (ord,chr)

square :: Int -> Int
square n = n * n

primes :: [Int]
primes = filterPrime [2..]
  where
    filterPrime (p:xs) =
       p : filterPrime [x | x <- xs, x `mod` p /= 0]

-- take :: Int -> [a] -> [a]

double :: Int -> Int
double n = 2*n

dubSq1 :: Int -> Int
dubSq1 n = double (square n)

dubSq2 :: Int -> Int
dubSq2 = double . square

-- Bool

nAnd :: Bool -> Bool -> Bool
nAnd x y = not (x && y)

nAnd2 :: Bool -> Bool -> Bool
nAnd2 True True = False
nAnd2 False False = False
nAnd2 x y = True

-- if, the, else

max2 :: Int -> Int -> Int
max2 x y = 
  if x >= y then x else y

-- Int

max3 :: Int -> Int -> Int -> Int
max3 a b c = max2 (max2 a b) c

f :: Int -> Int
f 1 = 0
f n = if  n `mod` 2 == 0 then n `div` 2 else 3*n + 1



isDigit :: Char -> Bool
isDigit ch = ('0' <= ch) && (ch <= '9')

isLower :: Char -> Bool
isLower ch = ('a' <= ch) && (ch <= 'z') -- no åäö in ASCII

offset :: Int
offset = ord 'A'  ord 'a'

toUpper :: Char -> Char
toUpper ch = chr (ord ch + offset)








f' 1 = 0
f' n
  | n `mod` 2 == 0 = n `div` 2
  | otherwise = 3*n + 1

life_length x
  | x == 1 = 0
  | otherwise = 1 + life_length(f' x)

Change History (2)

comment:1 Changed 3 years ago by RyanGlScott

Description: modified (diff)

comment:2 Changed 3 years ago by RyanGlScott

Operating System: MacOS XUnknown/Multiple
Resolution: duplicate
Status: newclosed

Thanks for the bug report.

This is a duplicate of #13106, which will be fixed in GHC 8.2. The issue arises because you're using functions that aren't defined. Here's the error message you get in GHC 8.2:

[1 of 1] Compiling Main             ( Bug.hs, interpreted )

Bug.hs:1:1: error:
    The IO action ‘main’ is not defined in module ‘Main’
  |
1 | module Main (main) where
  | ^

Bug.hs:58:18: error:
    Variable not in scope: (–) :: Int -> Int -> Int
   |
58 | offset = ord 'A' – ord 'a'
   |                  ^

So define (–) and main, and the panic should go away.

Note: See TracTickets for help on using tickets.