Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
marianopeck opened this issue Nov 23, 2015 · 0 comments
Open

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

marianopeck opened this issue Nov 23, 2015 · 0 comments

Comments

@marianopeck
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant