id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
2108	ghci is not tail recursive	george.colpitts		"Maybe ghci is not supposed to be tail recursive. I couldn't find anything specific to ghci or ghc but I found several places that said Haskell is tail recursive
To duplicate the bug
create a file that contains


{{{
fib :: Int -> Int -> Int -> Int
fib n prev curr  = 
    if n == 0 
      then curr 
      else fib (n -1) curr (prev + curr) 
}}}


then use :load to load it:

GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help[[BR]]
Loading package base ... linking ... done.[[BR]]
Prelude> :load work[[BR]]
[1 of 1] Compiling Main             ( work.hs, interpreted )[[BR]]
Ok, modules loaded: Main.[[BR]]
*Main> fib 10 0 1[[BR]]
89[[BR]]
*Main> fib 1234567 0 1[[BR]]
*** Exception: stack overflow[[BR]]
*Main> [[BR]]



same result if I do :set -fobject-code before loading except that it happens quicker


The function is tail recursive. It executes in Scheme with the same arguments (although extremely slowly because of the bignum arithmetic

If ghci and/or ghc are not tail recursive it would be good to document it.
Hopefully I have not missed something in the doc that explains this behavior

"	bug	closed	normal		GHCi	6.8.2	invalid			MacOS X	powerpc						
