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

Enable `block` variable in view #27303

Merged
merged 2 commits into from Dec 8, 2016

Conversation

Projects
None yet
5 participants
@toshimaru
Contributor

toshimaru commented Dec 8, 2016

Summary

Enabling block variable in view.

This fixes #27302

@rails-bot

This comment has been minimized.

Show comment
Hide comment
@rails-bot

rails-bot Dec 8, 2016

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.

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

This comment has been minimized.

Show comment
Hide comment
@matthewd

matthewd Dec 8, 2016

Member

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.

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.

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)

This comment has been minimized.

@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

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"]
@@ -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

This comment has been minimized.

@toshimaru

toshimaru Dec 8, 2016

Contributor

Not sure the constant naming and defined location are good.

@matthewd What do you think?

@toshimaru

toshimaru Dec 8, 2016

Contributor

Not sure the constant naming and defined location are good.

@matthewd What do you think?

toshimaru added some commits Dec 8, 2016

Enable `block` variable in view
Remove `block` keyword from reserved method names

@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 added a commit that referenced this pull request Dec 8, 2016

@matthewd

This comment has been minimized.

Show comment
Hide comment
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