[ruby-core:90860] [Ruby trunk Bug#8140] Incorrect warning: `+' after local variable is interpreted as binary operator

From: justin@...
Date: 2019-01-02 17:48:45 UTC
List: ruby-core #90860
Issue #8140 has been updated by jsc (Justin Collins).


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
~~~


----------------------------------------
Bug #8140: Incorrect warning: `+' after local variable is interpreted as binary operator
https://bugs.ruby-lang.org/issues/8140#change-76046

* Author: glyn (Glyn Normington)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
* ruby -v: ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-darwin12.2.1]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
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--------------------------------
parserbug.rb (293 Bytes)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next