Issue 3771 in pharo: avoid proposing a menu when nil is the doItReceiver of an interactive evaluation,

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

Issue 3771 in pharo: avoid proposing a menu when nil is the doItReceiver of an interactive evaluation,

pharo
Status: FixedWaitingToBePharoed
Owner: [hidden email]

New issue 3771 by [hidden email]: avoid proposing a menu when nil is  
the doItReceiver of an interactive evaluation,
http://code.google.com/p/pharo/issues/detail?id=3771

Name: Compiler-nice.187
Author: nice
Time: 4 February 2011, 10:17:14.337 pm
UUID: 71dd94ed-3fc7-49e0-b180-fb04be82bc29
Ancestors: Compiler-nice.184

In case nil is the doItReceiver of an interactive evaluation, avoid  
proposing a menu that would add an inst var to UndefinedObject.

=============== Diff against Compiler-nice.184 ===============

Item was added:
+ ----- Method: Parser>>canDeclareInstanceVariable (in category 'error  
correction') -----
+ canDeclareInstanceVariable
+       ^encoder classEncoding ~~ UndefinedObject!

Item was changed:
  ----- Method: UndeclaredVariable>>openMenuIn: (in category 'as yet  
unclassified') -----
  openMenuIn: aBlock
        | alternatives labels actions lines caption choice |
        alternatives := parser possibleVariablesFor: name.
        labels := OrderedCollection new.
        actions := OrderedCollection new.
        lines := OrderedCollection new.
        name first isLowercase
                ifTrue:
                        [labels add: 'declare method temp'.
                        actions add: [parser declareTemp: name at: #method].
                        labels add: 'declare block-local temp'.
                        actions add: [parser declareTemp: name at: #block].
+                       parser canDeclareClassVariable
+                               ifTrue:
+                                       [labels add: 'declare instance'.
+                                       actions add: [parser  
declareInstVar: name]]]
-                       labels add: 'declare instance'.
-                       actions add: [parser declareInstVar: name]]
                ifFalse:
                        [labels add: 'define new class'.
                        actions add: [parser defineClass: name].
                        labels add: 'declare global'.
                        actions add: [parser declareGlobal: name].
                        parser canDeclareClassVariable
                                ifTrue:
                                        [labels add: 'declare class  
variable'.
                                        actions add: [parser  
declareClassVar: name]]].
        lines add: labels size.
        alternatives do:
                [:each |
                labels add: each.
                actions add: [parser substituteVariable: each atInterval:  
interval]].
        lines add: labels size.
        labels add: 'cancel'.
        caption := 'Unknown variable: ' , name , ' please correct, or  
cancel:'.
        choice := aBlock value: labels value: lines value: caption.
        self resume: (actions at: choice ifAbsent: [nil])!