Bug #2365
closedMatrix: poor handling of coercion errors [patch]
Description
=begin
rubydev -r matrix -e 'p Matrix.I(2) - nil'
/usr/local/rubydev/lib/ruby/1.9.1/matrix.rb:533:in -': undefined method
coerce' for nil:NilClass (NoMethodError)
from -e:1:in `'
Expected:
some_where_in_the/matrix.rb:in -': nil can't be coerced into Matrix (TypeError) from -e:1:in
'
Same situation with Vector.
I'd be grateful if you could confirm the attached patch is ok.
=end
Files
Updated by ujihisa (Tatsuhiro Ujihisa) over 14 years ago
- Status changed from Open to Assigned
=begin
=end
Updated by keiju (Keiju Ishitsuka) over 14 years ago
- Status changed from Assigned to Rejected
=begin
This behavior is the same as an integer:
% ruby-dev -r matrix -e "p 2 - nil"
-e:1:in -': nil can't be coerced into Fixnum (TypeError) from -e:1:in
'
I think that these behavior is Ruby's standard behavior.
=end
Updated by runpaint (Run Paint Run Run) over 14 years ago
=begin
This behavior is the same as an integer:
% ruby-dev -r matrix -e "p 2 - nil"
-e:1:in-': nil can't be coerced into Fixnum (TypeError) from -e:1:in
'
I think that these behavior is Ruby's standard behavior.
As Marc-André explained, the behaviour is demonstrably different: Integer, correctly, raises a TypeError, whereas Matrix raises a NoMethodError. The latter is misleading because it exposes an irrelevant implementation detail (the use of #coerce) rather than describing the problem from the caller's perspective. The message associated with the exception is similarly wanting.
=end
Updated by marcandre (Marc-Andre Lafortune) over 14 years ago
- Status changed from Rejected to Open
=begin
Reopening the issue.
I feel frustation at such an unsatisfactory answer, coming 4 months after this simple request.
I wonder why Keiju insists on remaining maintainer.
=end
Updated by mame (Yusuke Endoh) over 14 years ago
=begin
Hi,
2010/3/30 Marc-Andre Lafortune redmine@ruby-lang.org:
Reopening the issue.
I feel frustation at such an unsatisfactory answer, coming 4 months after this simple request.
Think about something nice :-)
In any way, he finally answered the ticket before spec freezing.
I guess he just misunderstood the report. I believe that he'll
notice and correct his wrong answer soon.
--
Yusuke ENDOH mame@tsg.ne.jp
=end
Updated by mame (Yusuke Endoh) over 14 years ago
=begin
Hi, Marc-Andre
Are you willing to become a maintainer for matrix?
If so, I'll suggest Keiju resign, and ask matz's views whether
you are accepted as a new maintainer for matrix.
--
Yusuke ENDOH mame@tsg.ne.jp
=end
Updated by matz (Yukihiro Matsumoto) over 14 years ago
=begin
Hi,
In message "Re: [ruby-core:29113] Re: Bug #2365 Matrix: poor handling of coercion errors [patch]"
on Tue, 30 Mar 2010 03:22:56 +0900, Yusuke ENDOH mame@tsg.ne.jp writes:
|Are you willing to become a maintainer for matrix?
|
|If so, I'll suggest Keiju resign, and ask matz's views whether
|you are accepted as a new maintainer for matrix.
I agree. For 1.9.2, I don't think we have no time to update the
external API.
matz.
=end
Updated by mame (Yusuke Endoh) over 14 years ago
=begin
Hi, Marc-Andre
In [ruby-dev:40847], [ruby-dev:40849] and [ruby-core:29127],
Keiju and matz agreed with maintainer delegation to Marc-Andre.
So, you are now the maintainer for matrix.rb. Congrats!
http://redmine.ruby-lang.org/wiki/ruby/Maintainers
Keiju said that he was ambitious to rewrite matrix.rb in C,
and that he hoped you would take over it. IMO, there is
room to discuss about it, but I let you know that.
Note: Keiju continues to play the role of maintainer for other
libraries that he has maintained, such as irb, mathn, e2mmap,
etc.
--
Yusuke Endoh mame@tsg.ne.jp
=end
Updated by marcandre (Marc-Andre Lafortune) over 14 years ago
- Status changed from Open to Assigned
- Assignee changed from keiju (Keiju Ishitsuka) to marcandre (Marc-Andre Lafortune)
=begin
=end
Updated by marcandre (Marc-Andre Lafortune) over 14 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r27311.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
=end