Skip to content

Fix to #createBlockFor: since 'self' was being bound to nil. #4

@marianopeck

Description

@marianopeck

RBPatternBlockNode >> #createBlockFor: creates the closure in the way source evaluate and that makes the closure bind self with nil. And that breaks certain usage that expects self to be an instance of RBPatternBlockNode.

This is an example that simply breaks:

| 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions