
#9207: Detect obvious cases of infinite recursion. ------------------------------------+-------------------------------------- Reporter: mrugiero | Owner: Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: invalid | Keywords: infinite recursion Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: None/Unknown | Blocked By: Test Case: | Related Tickets: Blocking: | ------------------------------------+-------------------------------------- Comment (by simonpj): GHC already does a guaranteed-divergence analysis. For example {{{ f [] = f [True] f (x:xs) = f xs }}} If you say {{{ ghc -c -O -ddump-simpl Foo.hs }}} you get something like this {{{ Foo.f [Occ=LoopBreaker] :: forall t_aK7. [GHC.Types.Bool] -> t_aK7 [GblId, Arity=1, Str=DmdType b] }}} That "`b`" in teh `Str=` part says "bottom" meaning guaranteed divergence. but it does not distinguish an infnite loop from a call to `error`. So {{{ f [] = f [True] f (x:xs) = error "urk" }}} would give the same result. Maybe this information can help? Though some functions are ''supposed'' to return bottom. Eg {{{ myError :: String -> a myError s = error ("Bad bad bad: " ++ s) }}} Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9207#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler