[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>
Currently, ruby/spec is maintained mostly by individuals and enjoys the
13 messages
2016/12/13
[#78963] Re: ruby/spec needs help from CRuby committers
— Urabe Shyouhei <shyouhei@...>
2017/01/04
I did ask attendees of last developer meeting to join this
[#78642] Re: ruby/spec needs help from CRuby committers
— Eric Wong <normalperson@...>
2016/12/14
Benoit Daloze <eregontp@gmail.com> wrote:
[ruby-core:78728] [Ruby trunk Bug#13051] Object created with ARGF.class.new fails to update .lineno in .each
From:
lucasbuchala@...
Date:
2016-12-19 13:20:31 UTC
List:
ruby-core #78728
Issue #13051 has been reported by Lucas Buchala.
----------------------------------------
Bug #13051: Object created with ARGF.class.new fails to update .lineno in .each
https://bugs.ruby-lang.org/issues/13051
* Author: Lucas Buchala
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.4.0rc1 (2016-12-12 trunk 57064) [i686-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
I don't know if this way of creating ARGF-like objects is supported or not.
I just noticed that it didn't update the `.lineno` when used in `.each`.
Consider the example input file:
~~~
$ cat file1
foo
bar
baz
~~~
The following code:
~~~ruby
f = ARGF.class.new('file1')
f.each do |line|
puts "#{f.lineno} #{line}"
end
~~~
Outputs this:
~~~
0 foo
0 bar
0 baz
~~~
I was expecting this:
~~~
1 foo
2 bar
3 baz
~~~
If, instead of using `.each`, I read it in 2 steps with: `while line = f.gets; puts f.lineno; ...`, then it works, the line numbers are updated.
--
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>