[Glass] RefactoringBrowser (RB) failing to correctly bind "self" in closures?

Dale Henrichs via Glass glass at lists.gemtalksystems.com
Sun Nov 22 11:17:33 PST 2015


Cool ....

Now, tODE only loads AST-Core and I just checked and there _was_ only 
one test error (a test problem that I just fixed), so you must be using 
other parts of RB ....

Perhaps we could do a mini sprint for RB and get the tests passing for 
more of the system?

If you are interested perhaps you could let me know what sub-systems you 
are using and we could divvy up the tests?

Dale

On 11/22/15 10:58 AM, Mariano Martinez Peck wrote:
> OK, I found the place Dale, and now my tests DO work :)
> I replaced *"source evaluate"* with the below lines in bold.
>
> RBPatternBlockNode >> createBlockFor: aRBBlockNode
>   | source |
>   self replacePatternNodesIn: aRBBlockNode.
>   source := aRBBlockNode formattedCode.
> *  ^ (source*
> *    _compileInContext: self*
> *    symbolList: GsSession currentSession symbolList*
> *    oldLitVars: nil*
> *    environmentId: 0) _executeInContext: self*
> *
> *
> I will see if there are tests I can run from RB and next week I will 
> fork and commit fix.
>
> Thanks,
> *
> *
>
> On Fri, Nov 20, 2015 at 4:54 PM, Dale Henrichs via Glass 
> <glass at lists.gemtalksystems.com 
> <mailto:glass at lists.gemtalksystems.com>> wrote:
>
>     In tODE, I've been able to make `self` resolve to a proper object
>     by using the following to evaluate code:
>
>       | meth |
>       meth := self
>         _compileInContext: aContext
>         symbolList: symbolList
>         oldLitVars: litVarArray
>         environmentId: 0.
>       ^ meth _executeInContext: aContext
>
>     `self` is bound to aContext ... presumable RB is passing in a
>     `nil` arg there ....
>
>     If you have fixes for RB, please fork the RB project[1] and share
>     your fixes via a pull request.
>
>     Dale
>
>     [1] https://github.com/dalehenrich/rb
>
>     On 11/19/2015 12:17 PM, Mariano Martinez Peck via Glass wrote:
>>     Hi guys,
>>
>>     I have some code that uses RB and such code works correctly in
>>     Pharo but it fails in GemStone. It seems a problem with a closure
>>     which in Pharo "self" resolves to the real object while in
>>     GemStone resolves to nil.
>>
>>     The way to reproduce it is:
>>
>>     /| tree rewriter |/
>>     /tree := RBParser parseMethod: 'DoIt ^ [:proxy | proxy at:
>>     #oldSelector. ]'./
>>     /rewriter := RBParseTreeRewriter new./
>>     /rewriter /
>>     /replace: ('`#oldSelector `{:node | node value isSymbol and:
>>     [node value matchesRegex: ''.*oldSelector.*''] }')/
>>     /with: ('`{RBLiteralNode value: (`#oldSelector value
>>     copyReplaceAll: ''oldSelector'' with: ''newSelector'') asSymbol }')./
>>     /rewriter executeTree: tree./
>>     /rewriter tree newSource/
>>     And the problem is the line:
>>     /with: ('`{RBLiteralNode value: (`#oldSelector value
>>     copyReplaceAll: ''oldSelector'' with: ''newSelector'') asSymbol }')./
>>     which gets translated to:
>>     /
>>     [ :aDictionary |
>>     RBLiteralNode
>>       value:
>>         ((*self* lookupMatchFor: '`#oldSelector' in: aDictionary) value
>>           copyReplaceAll: 'oldSelector'
>>           with: 'newSelector') asSymbol ]
>>     /
>>     And the self there fails.
>>     Any idea how this is expected to work?
>>     Thanks in advance
>>
>>     -- 
>>     Mariano
>>     http://marianopeck.wordpress.com
>>
>>
>>     _______________________________________________
>>     Glass mailing list
>>     Glass at lists.gemtalksystems.com
>>     <mailto:Glass at lists.gemtalksystems.com>
>>     http://lists.gemtalksystems.com/mailman/listinfo/glass
>
>
>     _______________________________________________
>     Glass mailing list
>     Glass at lists.gemtalksystems.com <mailto:Glass at lists.gemtalksystems.com>
>     http://lists.gemtalksystems.com/mailman/listinfo/glass
>
>
>
>
> -- 
> Mariano
> http://marianopeck.wordpress.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20151122/b3f7f8b5/attachment-0001.html>


More information about the Glass mailing list