#2108: ghci is not tail recursive
--------------------------------+-------------------------------------------
Reporter: george.colpitts | Owner:
Type: bug | Status: new
Priority: normal | Component: GHCi
Version: 6.8.2 | Severity: normal
Keywords: | Testcase:
Architecture: powerpc | Os: MacOS X
--------------------------------+-------------------------------------------
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
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2108>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs