nioserver icon indicating copy to clipboard operation
nioserver copied to clipboard

compilation error with scalac 2.9.0

Open thosmos opened this issue 14 years ago • 2 comments

Hey Jim,

Thanks for your excellent work on a continuations server! I'm learning some scala by playing with it. :)

One problem I just had when I tried compiling it with the new 2.9.0 scala is the following. I didn't get this error with 2.8.1:

thosmac:scala thomas$ scalac -P:continuations:enable .scala net/jimmc//*.scala net/jimmc/nio/LineDecoder.scala:30: error: could not optimize @tailrec annotated method processChars: it contains a recursive call not in tail position processChars(cb, lineHandler) //handle multiple lines ^ one error found

Any ideas?

thosmos avatar May 13 '11 14:05 thosmos

thos37,

Sometimes tailrec and continuations don't mix very well. The CPS transformation can turn loops into recursion and recursion into loops. It may be that the 2.9 compiler is smarter about this so complains when it did not complain in 2.8.

I don't currently have the time to look into this in detail right now. You should be able to get around the tailrec problem by dropping that annotation, then see if it runs without a stack overflow. I will look into it next week.

Jim

On Fri, May 13, 2011 at 07:29:50AM -0700, thos37 wrote:

Date: Fri, 13 May 2011 07:29:50 -0700 From: thos37 [email protected] To: [email protected] Subject: [nioserver] compilation error with scalac 2.9.0 (#1)

Hey Jim,

Thanks for your excellent work on a continuations server! I'm learning some scala by playing with it. :)

One problem I just had when I tried compiling it with the new 2.9.0 scala is the following. I didn't get this error with 2.8.1:

thosmac:scala thomas$ scalac -P:continuations:enable .scala net/jimmc//*.scala net/jimmc/nio/LineDecoder.scala:30: error: could not optimize @tailrec annotated method processChars: it contains a recursive call not in tail position processChars(cb, lineHandler) //handle multiple lines ^ one error found

Any ideas?

jimmc avatar May 17 '11 06:05 jimmc

thos37,

It took me longer to get to it than expected, but I looked at the code and ended up simply removing the @tailrec annotation, as I had suggested below. The fact that the code is CPS means the recursion should effectively be turned into a loop that does not consume stack space. It ran my simple test, which is all I plan on doing for it. The code now compiles under 2.9.0, and I have uploaded the fix to github.

Jim

On Mon, May 16, 2011 at 11:32:15PM -0700, Jim McBeath wrote:

Date: Mon, 16 May 2011 23:32:15 -0700 From: Jim McBeath [email protected] To: thos37 [email protected] Subject: Re: [nioserver] compilation error with scalac 2.9.0 (#1)

thos37,

Sometimes tailrec and continuations don't mix very well. The CPS transformation can turn loops into recursion and recursion into loops. It may be that the 2.9 compiler is smarter about this so complains when it did not complain in 2.8.

I don't currently have the time to look into this in detail right now. You should be able to get around the tailrec problem by dropping that annotation, then see if it runs without a stack overflow. I will look into it next week.

Jim

On Fri, May 13, 2011 at 07:29:50AM -0700, thos37 wrote:

Date: Fri, 13 May 2011 07:29:50 -0700 From: thos37 [email protected] To: [email protected] Subject: [nioserver] compilation error with scalac 2.9.0 (#1)

Hey Jim,

Thanks for your excellent work on a continuations server! I'm learning some scala by playing with it. :)

One problem I just had when I tried compiling it with the new 2.9.0 scala is the following. I didn't get this error with 2.8.1:

thosmac:scala thomas$ scalac -P:continuations:enable .scala net/jimmc//*.scala net/jimmc/nio/LineDecoder.scala:30: error: could not optimize @tailrec annotated method processChars: it contains a recursive call not in tail position processChars(cb, lineHandler) //handle multiple lines ^ one error found

Any ideas?

jimmc avatar Jun 06 '11 19:06 jimmc