Confusing did_you_mean error
irb(main):001:0> test = some_string if (some_string = "test") (irb):1: warning: found = in conditional, should be == NameError: undefined local variable or method `some_string' for main:Object Did you mean? some_string from (irb):1 from /home/tgxworld/.rbenv/versions/2.3.1/bin/irb:11:in `<main>'
I think assignment in a one liner if statement isn't encouraged but I found the suggestion to be quite confusing.
Updated by shevegen (Robert A. Heiler) almost 3 years ago
I guess the trivial fix would be to:
"if the name would be the same name, do not suggest an alternative name"
(since the alternative name would be == to the reported name)
Has someone reported this on the github issue tracker for the did you mean it gem? Perhaps the gem author has not yet seen this report here.
I think assignment in a one liner if statement isn't encouraged
Yeah it is not encouraged but typos happen :-)
The did-you-mean-it gem even can work via typos like "def intialize", I think I
mentioned this once years ago. It is funny that someone else took the effort to
correct it. :-)
Perhaps we get better fine-tuned control of error or actually warning messages
in ruby 3.x era.
Updated by yuki24 (Yuki Nishijima) almost 3 years ago
- Assignee set to yuki24 (Yuki Nishijima)
- Status changed from Open to Third Party's Issue
I believe this issue has been fixed: https://github.com/yuki24/did_you_mean/commit/1c52c887c62b0921e799f94bcc4a846dc7cbc057
Could you try installing 1.0.2 of the
did_you_mean gem and see if it fixes your issue?
$ gem i did_you_mean -v=1.0.2 $ ruby -e'test = some_string if (some_string = "test")'