Enable `block` variable in view #27303

Merged
merged 2 commits into from Dec 8, 2016

Projects

None yet

5 participants

@toshimaru
Contributor
toshimaru commented Dec 8, 2016 edited

Summary

Enabling block variable in view.

This fixes #27302

@senny senny was assigned by rails-bot Dec 8, 2016
@rails-bot

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @senny (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@matthewd
Member
matthewd commented Dec 8, 2016

Instead of excluding the one value here, let's split DELEGATION_RESERVED_METHOD_NAMES in half, between the real keywords (most of them), and the couple (including block) that are just reserved in delegate because they're used in the implementation.

@@ -6,11 +6,12 @@ class Module
# option is not used.
class DelegationError < NoMethodError; end
+ RUBY_RESERVED_KEYWORDS = %w(alias and BEGIN begin break case class def defined? do
@toshimaru
toshimaru Dec 8, 2016 Contributor

Not sure the constant naming and defined location are good.

@matthewd What do you think?

+ RUBY_RESERVED_KEYWORDS = %w(alias and BEGIN begin break case class def defined? do
+ else elsif END end ensure false for if in module next nil not or redo rescue retry
+ return self super then true undef unless until when while yield)
+ DELEGATION_RESERVED_KEYWORDS = %w(_ arg args block)
@toshimaru
toshimaru Dec 8, 2016 Contributor

I extracted only delegation reserved keywords like this:

$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin15]

$ cat extract_keywords.rb
original_keywords = %w(_ arg args alias and BEGIN begin block break case class def defined? do else elsif END end ensure false for if in module next nil not or redo rescue retry return self super then true undef unless until when while yield)
keywords = []

original_keywords.each do |keyword|
  begin
    eval("#{keyword} = 1")
  rescue SyntaxError => e
    keywords << keyword
  end
end

p keywords
p original_keywords - keywords

$ ruby extract_keywords.rb
["alias", "and", "BEGIN", "begin", "break", "case", "class", "def", "defined?", "do", "else", "elsif", "END", "end", "ensure", "false", "for", "if", "in", "module", "next", "nil", "not", "or", "redo", "rescue", "retry", "return", "self", "super", "then", "true", "undef", "unless", "until", "when", "while", "yield"]
["_", "arg", "args", "block"]
toshimaru added some commits Dec 8, 2016
@toshimaru toshimaru Enable `block` variable in view
Remove `block` keyword from reserved method names
7407d35
@toshimaru toshimaru split DELEGATION_RESERVED_METHOD_NAMES in half
d9ff835
@matthewd matthewd merged commit 81608cd into rails:master Dec 8, 2016

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
codeclimate no new or fixed issues
Details
@matthewd
Member
matthewd commented Dec 8, 2016

96f0df1

@toshimaru toshimaru deleted the toshimaru:fix/partial-variable-block branch Dec 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment