My code is littered with warnings "cannot find 'messagename' for type 'Object'"
My code is littered with warnings of the form cannot find 'messagename' for type 'Object'"...
Am I missing something in the way I'm writing my code, or is this a useless warning (given that types can not be inferred statically in Ruby)? There are so many of them I can't easily find all the other warnings.
请先登录再写评论。
Hi Chez,
Ruby is a dynamic language, so RubyMine builtin type inference engine sometimes cannot cope with some particular cases. We are working hard on improving it constantly.
Could you please put caret on 'messagename' and launch action Goto declaration? (Ctrl+Click or Ctrl+B) Was it successful?
Maybe you use some wide spread metaprogramming trick which isn't yet supported yet?
Regards,
Oleg
> Ruby is a dynamic language, so RubyMine builtin type inference engine sometimes cannot cope with some particular cases. We are working hard on improving it constantly.
Agreed... which is why I wonder that it even reports anything in these cases. See my example code below.
> Could you please put caret on 'messagename' and launch action Goto declaration? (Ctrl+Click or Ctrl+B) Was it successful?
No.
> Maybe you use some wide spread metaprogramming trick which isn't yet supported yet?
Nope... simple Ruby.
Here's one simple example. Clearly the IDE shouldn't be able to determine p's type... there's no hinting on that because it is dynamically typed.
a_collection = get_old_invoices
r = a_collection.sum { |p| ( p.amt ) }
This code reports "Can not find 'amt' for type 'Object'"
There are so many of these yellow warnings on the right side of the window, it makes them usesless.
Hi Chez,

In some cases RubyMine can determine type of collection element, but in this particular case it couldn't, so we assume that p has Object type.
In this case you can either Supress inspection or disable it, but we don't recommend it, because it will be disabled for a whole project.
Hope this help,
Oleg
> In some cases RubyMine can determine type of collection element, but in this particular case it couldn't, so we assume that p has Object type.
It makes no sense to me to assume "object" in this case, as you would expect nearly zero % of variables in any well-written program to be of type Object. Thus, the warning becomes noise...
> In this case you can either Supress inspection or disable it, but we don't recommend it, because it will be disabled for a whole project.
I would much rather be suppress for any variable that can't be resolved to something more distinct that Object.
Let me ask you: when you look at any of your programs, don't you see this warning a lot?
(Thank you for your considerations... I love this product).
It is definitely a false positive and we are working hard on eliminating their quantity.
This one will be fixed soon, I've just offered a workaround.
http://youtrack.jetbrains.net/issue/RUBY-5512
Thanks for the issue,
Oleg
This issue was fixed, fix will be available in next major bug-fix version.
Sweet! Thanks.