Project

General

Profile

Bug #2365

Matrix: poor handling of coercion errors [patch]

Added by marcandre (Marc-Andre Lafortune) over 9 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 1.9.2dev (2009-11-08 trunk 25690) [x86_64-darwin10.0.0]
Backport:
[ruby-core:26736]

Description

=begin
rubydev -r matrix -e 'p Matrix.I(2) - nil'
/usr/local/rubydev/lib/ruby/1.9.1/matrix.rb:533:in -': undefined methodcoerce' 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

matrix_coercion.diff (3.76 KB) matrix_coercion.diff marcandre (Marc-Andre Lafortune), 11/14/2009 10:35 AM

History

#1

Updated by ujihisa (Tatsuhiro Ujihisa) over 9 years ago

  • Status changed from Open to Assigned

=begin

=end

#2

Updated by keiju (Keiju Ishitsuka) over 9 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

#3

Updated by runpaint (Run Paint Run Run) over 9 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

#4

Updated by marcandre (Marc-Andre Lafortune) over 9 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

#5

Updated by mame (Yusuke Endoh) over 9 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

#6

Updated by mame (Yusuke Endoh) over 9 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

#7

Updated by matz (Yukihiro Matsumoto) over 9 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

#8

Updated by mame (Yusuke Endoh) over 9 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

#9

Updated by marcandre (Marc-Andre Lafortune) over 9 years ago

  • Status changed from Open to Assigned
  • Assignee changed from keiju (Keiju Ishitsuka) to marcandre (Marc-Andre Lafortune)

=begin

=end

#10

Updated by marcandre (Marc-Andre Lafortune) over 9 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

Also available in: Atom PDF