[chuck-users] Scope bug?

warren at wamoco.com warren at wamoco.com
Thu Aug 7 13:23:38 EDT 2014


Possibly related (definitely perplexing): changing foo in A to “static”

 

class A 

{

    10000 => static int foo;

}

 

class B extends A 

{

    fun void bar()

    {

        0 => int foo;

 

        <<< "a", foo >>>;

        {

             <<< "b", foo >>>;

        }

        <<< "c", foo >>>;

    }

}

 

<<<A.foo>>>;

A a;

<<<a.foo>>>;

B b;

<<<b.foo>>>;

b.bar();

 

0 :(int)

10000 :(int)

-2031012 :(int)

a 0 

b 10000 

c 0

 

From: chuck-users-bounces at lists.cs.princeton.edu [mailto:chuck-users-bounces at lists.cs.princeton.edu] On Behalf Of Spencer Salazar
Sent: Wednesday, August 06, 2014 2:00 PM
To: ChucK Users Mailing List
Subject: Re: [chuck-users] Scope bug?

 

That looks like a bug alright. Thanks for letting us know! We will take a look into it. 

 

spencer

 

 

On Wed, Aug 6, 2014 at 10:56 AM, Dealga McArdle <tetha.z at gmail.com> wrote:

Ah, yes.. i see now

 

class A 

{

    10000 => int foo;

}

 

class B extends A 

{

    fun void bar()

    {

        0 => int foo;

 

        <<< "a", foo >>>;

        if (true) {

            <<< "b", foo >>>;

        }

        <<< "c", foo >>>;

    }

}

 

B bobj;

bobj.bar();

 

indeed.

 

On Wed, Aug 6, 2014 at 4:51 PM, Ian South-Dickinson <ian.southd at gmail.com> wrote:

The bug appears in other inner scopes, such as an if-statement, and probably for/while loops.

 

On Wed, Aug 6, 2014 at 7:40 AM, Dealga McArdle <tetha.z at gmail.com> wrote:

Ian, why do you have that innermost scope? that's not intended use of syntax I think.

 

On Wed, Aug 6, 2014 at 9:00 AM, Ian South-Dickinson <ian.southd at gmail.com> wrote:

I encountered a strange case where a variable was changing value within the scope of an if statement, because I had a superclass with an identical variable name. I am able to reproduce it with this simple case:

class A 
{
    10000 => int foo;
}

class B extends A 
{
    fun void bar()
    {
        0 => int foo;

        <<< "a", foo >>>;
        {
            <<< "b", foo >>>;
        }
        <<< "c", foo >>>;
    }
}

Prints out:

a 0 
b 10000 
c 0 

 

_______________________________________________
chuck-users mailing list
chuck-users at lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

 


_______________________________________________
chuck-users mailing list
chuck-users at lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

 


_______________________________________________
chuck-users mailing list
chuck-users at lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

 


_______________________________________________
chuck-users mailing list
chuck-users at lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20140807/0a126af4/attachment.html>


More information about the chuck-users mailing list