Another glitch in #824

It seems that RubyMine doesn't properly recognize instance allocation in
a non-static context (i.e. the class doing the instantiation is a
variable, not a constant) e.g.

class Foo
def initialize(*args)
puts "Foo.init: #{args.inspect}"
end
end

cls = Class.new(Foo)
cls.new('foo', 'bar') #=> Foo.init:


RubyMine highlights that last line as an error, claiming that there are
too many arguments.


cheers,
Charles

3 comments
Comment actions Permalink

Hello Charles,

It seems that RubyMine doesn't properly recognize instance allocation in

a non-static context (i.e. the class doing the instantiation is a
variable, not a constant) e.g.


class Foo
  def initialize(*args)
    puts "Foo.init: #{args.inspect}"
  end
end


cls = Class.new(Foo)
cls.new('foo', 'bar') #=> Foo.init: 'foo','bar'


RubyMine highlights that last line as an error, claiming that there are

too many arguments.

As far as Ruby is dynamic language it is rather hard to support all the possible variants of new instance allocations.
You can fill an issue on this problem in our bug tracker system, but I'm not sure it will be fixed somewhen.
There loads of dynamic trick and we don't have any chance to support all of them and now our main effort is to support Rails specific calls and smart completion for its arguments.

Thanks,
Oleg

0
Comment actions Permalink

Oleg,

That's ok, and usually rubymine is correct, which is very helpful, but
there isn't the option to suppress the inspection for the statement, so
I either need to disable the inspection entirely, or live with the IDE
telling me I have errors in my code.


Oleg Shpynov wrote:

Hello Charles,

It seems that RubyMine doesn't properly recognize instance allocation ina non-static context (i.e. the class doing the instantiation is a
> variable, not a constant) e.g.
>
> class Foo
> def initialize(*args)
> puts "Foo.init: #{args.inspect}"
> end
> end
>
> cls = Class.new(Foo)
> cls.new('foo', 'bar') #=> Foo.init: /'foo','bar'
>
>
> RubyMine highlights that last line as an error, claiming that there are
> too many arguments.
>

As far as Ruby is pretty dynamic language is rather hard to support all the possible variants of new instance allocations.
You can fill an issue on this problem in our bug tracker system, but I'm not sure it will be fixed somewhen.
There loads of dynamic trick and we don't have any chance to support all of them and now our main effort is to support Rails specific calls and smart completion for its arguments.

Thanks,
Oleg

---
Original message URL: http://www.jetbrains.net/devnet/message/5235676#5235676

0
Comment actions Permalink

Hello,

That's ok, and usually rubymine is correct, which is very helpful, but
there isn't the option to suppress the inspection for the statement, so
I either need to disable the inspection entirely, or live with the IDE
telling me I have errors in my code.

I've filled an issue: http://www.jetbrains.net/jira/browse/RUBY-3680
Feel free to vote and track progress on it.

Regards,
Oleg

0

Please sign in to leave a comment.