Actions
Bug #8140
closedIncorrect warning: `+' after local variable is interpreted as binary operator
Description
The statement:
puts '' +''
generates an invalid warning when executed with "ruby -w" which (a) implies a syntactical ambiguity where there is none, and (b) refers to a "local variable" of which there are none.
Note that:
puts ''+''
and:
puts '' + ''
produce no warnings.
Files
Updated by jsc (Justin Collins) over 6 years ago
glyn (Glyn Normington) wrote:
The statement:
puts '' +''
generates an invalid warning when executed with "ruby -w" which (a) implies a syntactical ambiguity where there is none, and (b) refers to a "local variable" of which there are none.
The message as of ruby-1.9.3-p551 was:
$ ruby -w
'' +''
-:1: warning: `+' after local variable is interpreted as binary operator
-:1: warning: even though it seems like unary operator
As of 2.1.10 (at least), the message now includes "or literal" to address point (b):
$ ruby -w
'' +''
-:1: warning: `+' after local variable or literal is interpreted as binary operator
-:1: warning: even though it seems like unary operator
Updated by jeremyevans0 (Jeremy Evans) almost 6 years ago
- Status changed from Open to Closed
Actions
Like0
Like0Like0