Hi,

consider this program:

> module Main (f, main) where
> 
> f ~(a:as) = 1 + f as
> 
> main = print $ f (error "Foobar!")

Obviously, the program should result in an error - the irrefutable
pattern of f always succeeds, so f calls itself recursively ad
infinitum and the result is <<Loop>> or nontermination.

Or so I thought. Running this program after compiling with ghc -O
(with 6.4.2, 6.6 and 6.7) results in:

  a.out: Foobar!

So the 'error "Foobar!"' got evaluated. The compiler somehow replaced
one 'bottom' with another which is arguably allowed. I wasn't able to
come up with an example where it turned a bottom into a value or vice
versa.

Anyway, this looks suspicious to me, so what's happening here?

regards,

Bertram
_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to