[ruby-core:76319] [Ruby trunk Bug#12569][Closed] There is no any warnings or errors with wrong comma after last attr_accessor attribute

From: nobu@...
Date: 2016-07-08 12:34:27 UTC
List: ruby-core #76319
Issue #12569 has been updated by Nobuyoshi Nakada.

Description updated
Status changed from Open to Closed

Try with `-w` option.

----------------------------------------
Bug #12569: There is no any warnings or errors with wrong comma after last attr_accessor attribute
https://bugs.ruby-lang.org/issues/12569#change-59554

* Author: Roman Krasavtsev
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
In second sample we don't have any warnings or errors with wrong comma after last  attr_accessor attribute and without it is very difficult to identify the typo. initialize method does not performed.

## It works
```ruby
class Solution
  attr_accessor :one, :two, :three

  def initialize
    @one = @two = @three = []
    puts "Done!"
  end
end

solution = Solution.new
p solution.one
p solution.two
p solution.three
```
## Result:
```
MacBook-Air-Roman% ruby ruby_solution.rb
Done!
[]
[]
[]
```
## it does not work
```ruby
class Solution
  attr_accessor :one, :two, :three,

  def initialize
    @one = @two = @three = []
    puts "Done!"
  end
end

solution = Solution.new
p solution.one
p solution.two
p solution.three
```
## Result
```
MacBook-Air-Roman% ruby ruby_solution.rb
nil
nil
nil
```



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

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next