Issue 5566 in pharo: Global ClassVar broken scope

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 5566 in pharo: Global ClassVar broken scope

pharo
Status: Accepted
Owner: [hidden email]
Labels: Milestone-1.4 Importance-High

New issue 5566 by [hidden email]: Global ClassVar broken scope
http://code.google.com/p/pharo/issues/detail?id=5566

Smalltalk at: #Foo put: #Foo.

Then define a class:

Object subclass: #FooTest
        instanceVariableNames: ''
        classVariableNames: 'Foo'     "This is the trigger"
        poolDictionaries: ''
        category: 'ClassVar-Testing'


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5566 in pharo: Global ClassVar broken scope

pharo

Comment #1 on issue 5566 by [hidden email]: Global ClassVar broken scope
http://code.google.com/p/pharo/issues/detail?id=5566

There is a bug report about this from one year ago: Issue 3647


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5566 in pharo: Global ClassVar broken scope

pharo

Comment #2 on issue 5566 by [hidden email]: Global ClassVar broken  
scope
http://code.google.com/p/pharo/issues/detail?id=5566

Issue 3647 has been merged into this issue.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5566 in pharo: Global ClassVar broken scope

pharo
In reply to this post by pharo

Comment #4 on issue 5566 by [hidden email]: Global ClassVar broken  
scope
http://code.google.com/p/pharo/issues/detail?id=5566

I have the impression that the bug is more in the logic of the class  
builder.

Because
        - if we create first the class var, and compile a method, it is found in  
the class,
        - if we create the global first (and not the class var) it is found.
       
        - if I create a class var, then a global then I create a method and it  
will access the class var
        Now I can change the value of the global var and I still get the value of  
the class var

so the lookup is working.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5566 in pharo: Global ClassVar broken scope

pharo

Comment #5 on issue 5566 by [hidden email]: Global ClassVar broken  
scope
http://code.google.com/p/pharo/issues/detail?id=5566

Now

Object subclass: #FooTest
        instanceVariableNames: ''
        classVariableNames: 'Plouf'
        poolDictionaries: ''
        category: 'Zinc-Tests'

And then if after I define

Smalltalk at: #Plouf put: 255

then I redefine

Object subclass: #FooTest
        instanceVariableNames: ''
        classVariableNames: 'Plouf'
        poolDictionaries: ''
        category: 'Zinc-Tests'


I do not get the problem


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5566 in pharo: Global ClassVar broken scope

pharo

Comment #6 on issue 5566 by [hidden email]: Global ClassVar broken  
scope
http://code.google.com/p/pharo/issues/detail?id=5566

The problem comes from #declare: in class. If you remove the check and  
raise of DuplicatedVariableError, it works.

DuplicatedVariableError other uses are strange, too. E.g. I can't add an  
instvar of the same name anywhere in the hierarchy.But I need that if I  
want to move methods in the hierarchy from a subclass that defines a var to  
the superclass... (e.g. try to merge ExpandedSourceFileArray into  
SourceFileArray... you can't add a variable 'files' in the superclass).


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5566 in pharo: Global ClassVar broken scope

pharo

Comment #7 on issue 5566 by [hidden email]: Global ClassVar broken  
scope
http://code.google.com/p/pharo/issues/detail?id=5566

The problem comes from #declare: in class. If you remove the check and  
raise of DuplicatedVariableError, it works.

DuplicatedVariableError other uses are strange, too. E.g. I can't add an  
instvar of the same name anywhere in the hierarchy.But I need that if I  
want to move methods in the hierarchy from a subclass that defines a var to  
the superclass... (e.g. try to merge ExpandedSourceFileArray into  
SourceFileArray... you can't add a variable 'files' in the superclass).


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5566 in pharo: Global ClassVar broken scope

pharo

Comment #8 on issue 5566 by [hidden email]: Global ClassVar broken  
scope
http://code.google.com/p/pharo/issues/detail?id=5566

Yes it looks like the problem.



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5566 in pharo: Global ClassVar broken scope

pharo

Comment #9 on issue 5566 by [hidden email]: Global ClassVar broken  
scope
http://code.google.com/p/pharo/issues/detail?id=5566

I propose to remove the check. I think that check cannot work well since we  
do not get the scope of the duplicate variables. This is the question of  
the shadowing of variables.


declare: varString
        "Declare class variables common to all instances. Answer whether
        recompilation is advisable."

        | newVars conflicts |
        newVars :=
                (varString subStrings: ' ')
                        collect: [:x | x asSymbol].
        conflicts := false.
        classPool == nil
                ifFalse: [(classPool keys reject: [:x | newVars includes: x]) do:
                                        [:var | self removeClassVarNamed: var]].
        newVars size > 0
                ifTrue:
                        [classPool := self classPool.
                        "in case it was nil"
                        newVars do: [:var | classPool declare: var from: Undeclared]].
        ^conflicts


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5566 in pharo: Global ClassVar broken scope

pharo
Updates:
        Status: FixToInclude

Comment #10 on issue 5566 by [hidden email]: Global ClassVar broken  
scope
http://code.google.com/p/pharo/issues/detail?id=5566

I found the solution. We should call the innerBindingOf: because the  
duplication check should only take into
the class variable and not the environment.

declare: varString
        "Declare class variables common to all instances. Answer whether
        recompilation is advisable."

        | newVars conflicts |
        newVars :=
                (varString subStrings: ' ')
                        collect: [:x | x asSymbol].
        conflicts := false.
        classPool == nil
                ifFalse: [(classPool keys reject: [:x | newVars includes: x]) do:
                                        [:var | self removeClassVarNamed: var]].
        (newVars reject: [:var | self classPool includesKey: var])
                do: [:var | "adding"
                        "check if new vars defined elsewhere"
                        (self innerBindingOf: var) notNil
                                ifTrue:
                                        [(DuplicatedVariableError new) variable: var;
                                                signal: var , ' is defined elsewhere'.
                                        conflicts := true]].
        newVars size > 0
                ifTrue:
                        [classPool := self classPool.
                        "in case it was nil"
                        newVars do: [:var | classPool declare: var from: Undeclared]].
        ^conflicts


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5566 in pharo: Global ClassVar broken scope

pharo

Comment #11 on issue 5566 by [hidden email]: Global ClassVar broken  
scope
http://code.google.com/p/pharo/issues/detail?id=5566

Hmm... now the conflicts variable is always false.

We should check the sender to see what it does.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5566 in pharo: Global ClassVar broken scope

pharo

Comment #12 on issue 5566 by [hidden email]: Global ClassVar broken  
scope
http://code.google.com/p/pharo/issues/detail?id=5566

I checked and I get the right error
        - when I define a class var that is defined in the super class
        - or a class var with the same name that another one in the same class

So to me it looks working.



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5566 in pharo: Global ClassVar broken scope

pharo
Updates:
        Status: Integrated

Comment #13 on issue 5566 by [hidden email]: Global ClassVar broken  
scope
http://code.google.com/p/pharo/issues/detail?id=5566

added the attached version (slight cleanup in addition (no size > 0)

14416



Attachments:
        Class-declare.st  983 bytes


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker