This page is no longer maintained — Please continue to the home page at www.scala-lang.org

"recursive variable needs type"

4 replies
Russ P.
Joined: 2009-01-31,
User offline. Last seen 1 year 26 weeks ago.
I am baffled by this error message:

[error] State.scala:326: recursive variable time needs type
[error]         val time1 = time + dt

Here is the code that is producing it (it is part of a class definition):

    def turnByAngle(
        turnang: Scalar, // turn angle, positive clockwise
        duration: Scalar, // time duration of prediction
        dt: Scalar, // prediction time step
        bankang: Scalar=20*deg, // bank angle for coordinated turn
        wind: Vector=Vector(0,0) // optional wind vector
        ): PathPrediction = {

        val time0 = timeTag // time of latest radar update
        var time = prevmult(time0, dt) // prediction start time
        val time1 = time + dt

I have tried various tests, such as declaring explicit types and replacing the "prevmult" call with zero (Scalar(0)), but I still get the same basic error message. Does anyone have a clue about what might be going on here? I am using Scala 2.8.0.Beta1-RC8 on Red Hat 4. I plan to upgrade to 2.8 as soon as it is released, unless someone tells me that this error is the result of a compiler bug that has been fixed. I hope I am not missing something ridiculously obvious. Thanks.

Russ P.

--
http://RussP.us
Tony Sloane
Joined: 2009-01-07,
User offline. Last seen 2 years 32 weeks ago.
Re: "recursive variable needs type"

On 23/06/2010, at 10:09 AM, Russ Paielli wrote:
I am baffled by this error message:

[error] State.scala:326: recursive variable time needs type
[error]         val time1 = time + dt

Here is the code that is producing it (it is part of a class definition):

    def turnByAngle(
        turnang: Scalar, // turn angle, positive clockwise
        duration: Scalar, // time duration of prediction
        dt: Scalar, // prediction time step
        bankang: Scalar=20*deg, // bank angle for coordinated turn
        wind: Vector=Vector(0,0) // optional wind vector
        ): PathPrediction = {

        val time0 = timeTag // time of latest radar update
        var time = prevmult(time0, dt) // prediction start time
        val time1 = time + dt

I have tried various tests, such as declaring explicit types and replacing the "prevmult" call with zero (Scalar(0)), but I still get the same basic error message. Does anyone have a clue about what might be going on here? I am using Scala 2.8.0.Beta1-RC8 on Red Hat 4. I plan to upgrade to 2.8 as soon as it is released, unless someone tells me that this error is the result of a compiler bug that has been fixed. I hope I am not missing something ridiculously obvious. Thanks.

I'm not sure what the problem is from this code snippet.  What is timeTag? 
BTW, you are using a very old version that dates from January.  Have you tried with the latest 2.8 RC, which is 2.8.0.RC6.
cheers,Tony
Russ P.
Joined: 2009-01-31,
User offline. Last seen 1 year 26 weeks ago.
Re: "recursive variable needs type"


On Tue, Jun 22, 2010 at 5:13 PM, Tony Sloane <inkytonik@gmail.com> wrote:

I'm not sure what the problem is from this code snippet.  What is timeTag? 
It's a Scalar type data field of the State class.
 
BTW, you are using a very old version that dates from January.  Have you tried with the latest 2.8 RC, which is 2.8.0.RC6.
 If that's a possible cause of this error message, I'll try it, otherwise I'd rather just wait for the final 2.8.

--Russ P

--
http://RussP.us
Tony Sloane
Joined: 2009-01-07,
User offline. Last seen 2 years 32 weeks ago.
Re: "recursive variable needs type"
On 23/06/2010, at 10:20 AM, Russ Paielli wrote:
On Tue, Jun 22, 2010 at 5:13 PM, Tony Sloane <inkytonik@gmail.com> wrote:

I'm not sure what the problem is from this code snippet.  What is timeTag? 
It's a Scalar type data field of the State class.

Hmm, that should be OK then, since it is hard to see how timeTag can be defined in terms of the locals "time" or "time1" inside turnByAngle. 
BTW, you are using a very old version that dates from January.  Have you tried with the latest 2.8 RC, which is 2.8.0.RC6.
 If that's a possible cause of this error message, I'll try it, otherwise I'd rather just wait for the final 2.8.

Well, you never know.  Many bug fixes have been applied since January, so it's possible that your problem goes away.  If it's possible to send me a (should be) compilable fragment, I can try it on 2.8.0.RC6 for you, if you like.
cheers,Tony
Stefan Langer
Joined: 2009-10-23,
User offline. Last seen 42 years 45 weeks ago.
Re: "recursive variable needs type"

Not sure why this happens from your code snippet but simply try adding
a type annotation to your time val and see if the compiler still
complains. If it does upgrade.
Btw you can simply use sbaz to update your scala version.

-Stefan

2010/6/23 Tony Sloane :
> On 23/06/2010, at 10:20 AM, Russ Paielli wrote:
>
> On Tue, Jun 22, 2010 at 5:13 PM, Tony Sloane wrote:
>>
>> I'm not sure what the problem is from this code snippet.  What is
>> timeTag?
>
> It's a Scalar type data field of the State class.
>
> Hmm, that should be OK then, since it is hard to see how timeTag can be
> defined in terms of the locals "time" or "time1" inside turnByAngle.
>>
>> BTW, you are using a very old version that dates from January.  Have you
>> tried with the latest 2.8 RC, which is 2.8.0.RC6.
>
>  If that's a possible cause of this error message, I'll try it, otherwise
> I'd rather just wait for the final 2.8.
>
> Well, you never know.  Many bug fixes have been applied since January, so
> it's possible that your problem goes away.  If it's possible to send me a
> (should be) compilable fragment, I can try it on 2.8.0.RC6 for you, if you
> like.
> cheers,
> Tony
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland