Project

General

Profile

Actions

Bug #12037

closed

did_you_mean reporting impossible suggestion

Added by chrisarcand (Chris Arcand) almost 9 years ago. Updated almost 9 years ago.

Status:
Third Party's Issue
Target version:
-
[ruby-core:73589]

Description

The did_you_mean feature in Ruby 2.3.0 reports an impossible suggestion when you define whatever is being called in the current scope after it is being called:

irb(main):001:0> def foo
irb(main):002:1> bar
irb(main):003:1> bar = "baz"
irb(main):004:1> end
=> :foo
irb(main):005:0> foo
NameError: undefined local variable or method `bar' for main:Object
Did you mean?  bar
        from (irb):2:in `foo'
        from (irb):5
        from /Users/carcand/.rbenv/versions/2.3.0/bin/irb:11:in `<main>'

I imagine this could be very confusing for newcomers to Ruby; I've not looked in to how the gem works but if a way to suppress the suggestion in this particular context might be appropriate.

Updated by nobu (Nobuyoshi Nakada) almost 9 years ago

  • Status changed from Open to Third Party's Issue
  • Assignee set to yuki24 (Yuki Nishijima)

Probably the same name as the erred should be removed from candidates first.

Updated by duerst (Martin Dürst) almost 9 years ago

Issue #12037 has been updated by Nobuyoshi Nakada.

Status changed from Open to Third Party's Issue
Assignee set to Yuki Nishijima

Probably the same name as the erred should be removed from candidates first.

Even better, why not create a more explicit message for such a case, e.g.

NameError: undefined local variable or method `bar' for main:Object
Attempt to use before created:
from (irb):2:in `foo'
from (irb):5
from /Users/carcand/.rbenv/versions/2.3.0/bin/irb:11:in `<main>'

Updated by yuki24 (Yuki Nishijima) almost 9 years ago

fixed in yuki24/did_you_mean@1c52c88. Thank you Chris for reporting this issue!

Martin, your idea sounds great to me, but I think it sounds more like a feature. Could you create a new issue so we can hear from other committers?

Updated by duerst (Martin Dürst) almost 9 years ago

Yuki Nishijima wrote:

Martin, your idea sounds great to me, but I think it sounds more like a feature. Could you create a new issue so we can hear from other committers?

Yuki, I can do that, but do we really need feature requests for gems?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0