I understand what the following warning means:
-:1: warning: useless use of a variable in void context
But I don't understand why ERB in Ruby 1.8.7 generates code that uses _erbout
variable in void context:
$ rvm use ruby 1.8.7
Using /Users/radeksimko/.rvm/gems/ruby-1.8.7-head
$ touch test.erb
$ erb -x test.erb
_erbout = ''; _erbout
$ erb -x test.erb | ruby -w
-:1: warning: useless use of a variable in void context
This is not a problem in ERB / Ruby 2.0.0+ though as ERB generates code from the template differently:
$ rvm use 2.0.0
Using /Users/radeksimko/.rvm/gems/ruby-2.0.0-p598
$ erb -x test.erb
#coding:ASCII-8BIT
_erbout = ''; _erbout.force_encoding(__ENCODING__)
$ erb -x test.erb | ruby -w
$
To be clear, this has nothing to do with _
(underscores) treating in variable names in between Ruby versions:
$ rvm use 2.0.0
Using /Users/radeksimko/.rvm/gems/ruby-2.0.0-p598
$ echo "erbout = ''; erbout" | ruby -w
-:1: warning: possibly useless use of a variable in void context
$ rvm use 1.8.7
Using /Users/radeksimko/.rvm/gems/ruby-1.8.7-head
$ echo "erbout = ''; erbout" | ruby -w
-:1: warning: useless use of a variable in void context
Is this a bug that should be reported to Ruby/ERB core or am I just misunderstanding something?