From: "vo.x (Vit Ondruch) via ruby-core" Date: 2025-11-28T15:10:32+00:00 Subject: [ruby-core:123939] [Ruby Bug#21718] TypeError:wrong argument type ... (expected Array) Issue #21718 has been updated by vo.x (Vit Ondruch). In retrospect, is the `instance_variables_to_inspect` design good? Wouldn't it be better if such method behaved as some filter? E.g. it would get e.g. an array of something (maybe list of instance variables?), which could be altered and returned afterwards? And maybe such method should be always defined, to prevent surprises with `method_missing`? Just thinking loud ... ---------------------------------------- Bug #21718: TypeError:wrong argument type ... (expected Array) https://bugs.ruby-lang.org/issues/21718#change-115338 * Author: vo.x (Vit Ondruch) * Status: Open * ruby -v: ruby 4.0.0dev (2025-11-18 master 85abc59c32) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- Testing Ruby 4.0 on Fedora, we observe these errors in [MiniMagick](https://github.com/minimagick/minimagick/) ~~~ 1) MiniMagick::Image#composite yields an optional block Failure/Error: yield composite if block_given? TypeError: wrong argument type MiniMagick::Tool (expected Array) # ./lib/mini_magick/image.rb:515:in 'block in MiniMagick::Image#composite' # ./lib/mini_magick/tool.rb:34:in 'MiniMagick::Tool.new' # ./lib/mini_magick.rb:28:in 'block (2 levels) in module:MiniMagick' # ./lib/mini_magick/image.rb:514:in 'MiniMagick::Image#composite' # ./spec/lib/mini_magick/image_spec.rb:609:in 'block (4 levels) in ' # ./spec/lib/mini_magick/image_spec.rb:610:in 'block (3 levels) in ' ~~~ and [Vagrant](https://github.com/hashicorp/vagrant) / [vagrant-libvirt](https://github.com/vagrant-libvirt/vagrant-libvirt) ~~~ 340) VagrantPlugins::ProviderLibvirt::Util::NetworkUtil #libvirt_networks should retrieve the list of networks Failure/Error: let(:machine) { iso_env.machine(:test, :libvirt) } TypeError: wrong argument type Vagrant::Config::V2::DummyConfig (expected Array) # /usr/share/vagrant/gems/gems/vagrant-2.3.4/plugins/kernel_v2/config/vm.rb:713:in 'Kernel#inspect' # /usr/share/vagrant/gems/gems/vagrant-2.3.4/plugins/kernel_v2/config/vm.rb:713:in 'VagrantPlugins::Kernel_V2::VMConfig#get_provider_config' # /usr/share/vagrant/gems/gems/vagrant-2.3.4/lib/vagrant/vagrantfile.rb:75:in 'Vagrant::Vagrantfile#machine' # /usr/share/vagrant/gems/gems/vagrant-2.3.4/lib/vagrant/environment.rb:740:in 'Vagrant::Environment#machine' # ./spec/support/unit_context.rb:26:in 'block (2 levels) in ' # ./spec/support/unit_context.rb:37:in 'block (2 levels) in ' # ./spec/support/unit_context.rb:51:in 'block (3 levels) in ' # ./spec/support/unit_context.rb:43:in 'block (2 levels) in ' # /usr/share/rubygems/rubygems.rb:303:in 'Kernel#load' # /usr/share/rubygems/rubygems.rb:303:in 'Gem.activate_and_load_bin_path' ~~~ Trying to investigate closer the vagrant-libvirt case, I really cannot wrap my head around it, because it fails with innocently looking `result.inspect` [1]. The image_magick fails at `yield composite if block_given?` line, so I suspect that the `yield composite` is the specific place. Since this does not make any sense to me, I have grepped the Ruby source code for: ~~~ $ grep -R -e TypeError | grep "wrong argument type.*Array" ... snip ... prism/extension.c: rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Array)", rb_obj_class(scopes)); prism/extension.c: rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Array)", rb_obj_class(locals)); prism/extension.c: rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Array)", rb_obj_class(names)); ~~~ This seems to come from https://github.com/ruby/prism/commit/21abb6b7c499b41a951eba7c8219c336a656da40 . So is it the reason? Not sure. [1]: https://github.com/hashicorp/vagrant/blob/986a01734f008d62897bb66085381090e4fcabfc/plugins/kernel_v2/config/vm.rb#L712 [2]: https://github.com/minimagick/minimagick/blob/ddcbfe9632667876be10373e1e01252617e74057/lib/mini_magick/image.rb#L515 -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/