Skip to content

Fix for warnings on Ruby 2.5 in ERB binding #544

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

Merged

Conversation

aycabta
Copy link
Member

@aycabta aycabta commented Oct 16, 2017

ERB requires variable context as Binding object and Darkfish uses Kernel#binding for it, but it causes warnings "assigned but unused variable" on Ruby 1.9 or later, so there ware "suppress 1.9.3 warning" code like below:

# suppress 1.9.3 warning
variable = variable = expressions

The variable variable is assigned but unused at this scope and used inside ERB template, so the double assign of variable is for suppress the warning.

This code causes warning "assigned but unused variable" on Ruby 2.5 again. I fixed it with Binding#local_variable_set for "use" variable.

This Pull Request removes Ruby 2.5 warnings in tests below:

/path/to/rdoc/lib/rdoc/generator/darkfish.rb:317: warning: assigned but unused variable - asset_rel_prefix
/path/to/rdoc/lib/rdoc/generator/darkfish.rb:347: warning: assigned but unused variable - asset_rel_prefix
/path/to/rdoc/lib/rdoc/generator/darkfish.rb:348: warning: assigned but unused variable - svninfo
/path/to/rdoc/lib/rdoc/generator/darkfish.rb:420: warning: assigned but unused variable - asset_rel_prefix
/path/to/rdoc/lib/rdoc/generator/darkfish.rb:402: warning: assigned but unused variable - current
/path/to/rdoc/lib/rdoc/generator/darkfish.rb:462: warning: assigned but unused variable - current
/path/to/rdoc/lib/rdoc/generator/darkfish.rb:463: warning: assigned but unused variable - asset_rel_prefix
/path/to/rdoc/lib/rdoc/generator/darkfish.rb:487: warning: assigned but unused variable - asset_rel_prefix
/path/to/rdoc/lib/rdoc/generator/darkfish.rb:544: warning: assigned but unused variable - asset_rel_prefix

ERB requires variable context as Binding object and Darkfish uses
Kernel#binding for it, but it causes warnings "assigned but unused
variable" on Ruby 1.9 or later, so there ware "suppress 1.9.3 warning"
code like below:

  # suppress 1.9.3 warning
  variable = variable = expressions

The "variable" variable is assigned but unused *at this scope* and used
inside ERB template, so the double assign of "variable" is for suppress
the warning.

This code causes warning "assigned but unused variable" on Ruby 2.5
again. I fixed it with Binding#local_variable_set for "use" variable.
@hsbt
Copy link
Member

hsbt commented Oct 24, 2017

Looks good.

@hsbt hsbt merged commit a9f98ba into ruby:master Oct 24, 2017
@aycabta aycabta deleted the fix-for-warnings-with-ruby25-in-erb-binding branch October 24, 2017 10:55
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

Successfully merging this pull request may close these issues.

2 participants