{"record":{"id":"3e7dba6b5ac876a6","repo":"ruby-concurrency/concurrent-ruby","slug":"wrong-number-of-arguments-0-for-1-3e7dba","errorCode":null,"errorMessage":"wrong number of arguments (0 for 1+)","messagePattern":"wrong number of arguments \\(0 for 1\\+\\)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/concurrent-ruby/concurrent/settable_struct.rb","lineNumber":108,"sourceCode":"    rescue NoMethodError\n      raise NameError.new(\"no member '#{member}' in struct\")\n    end\n\n    private\n\n    # @!visibility private\n    def initialize_copy(original)\n      synchronize do\n        super(original)\n        ns_initialize_copy\n      end\n    end\n\n    # @!macro struct_new\n    def self.new(*args, &block)\n      clazz_name = nil\n      if args.length == 0\n        raise ArgumentError.new('wrong number of arguments (0 for 1+)')\n      elsif args.length > 0 && args.first.is_a?(String)\n        clazz_name = args.shift\n      end\n      FACTORY.define_struct(clazz_name, args, &block)\n    end\n\n    FACTORY = Class.new(Synchronization::LockableObject) do\n      def define_struct(name, members, &block)\n        synchronize do\n          clazz = Synchronization::AbstractStruct.define_struct_class(SettableStruct, Synchronization::LockableObject, name, members, &block)\n          members.each_with_index do |member, index|\n            clazz.send :remove_method, member if clazz.instance_methods.include? member\n            clazz.send(:define_method, member) do\n              synchronize { @values[index] }\n            end\n            clazz.send(:define_method, \"#{member}=\") do |value|\n              synchronize do\n                unless @values[index].nil?","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/ruby-concurrency/concurrent-ruby/blob/0b88d5ff75f69b3740c8f0868e76f833cb2fd45d/lib/concurrent-ruby/concurrent/settable_struct.rb#L90-L126","documentation":"SettableStruct.new is the class factory that defines a new struct class, not an instance constructor: it requires at least one argument (a member list, optionally preceded by a String class name). Calling it with zero arguments raises ArgumentError('wrong number of arguments (0 for 1+)'). Instances are created afterwards by calling new (or []) on the generated class, where values are optional.","triggerScenarios":"Concurrent::SettableStruct.new with no args; intending to instantiate an already-defined struct class but calling the factory by mistake (MyStruct is right, SettableStruct.new is wrong); copy-paste that drops the member symbols.","commonSituations":"Confusion between the definition step and the instantiation step, which differs from core Struct's ergonomics; scaffolding code generated without a member list.","solutions":["Define the class with members: Point = Concurrent::SettableStruct.new(:x, :y)","Instantiate via the generated class: Point.new(1, 2) — values may be omitted there","If you only need a mutable record with no fixed schema, use a Hash or Struct from core Ruby instead"],"exampleFix":"# before\nStruct = Concurrent::SettableStruct.new # ArgumentError\n\n# after\nPoint = Concurrent::SettableStruct.new(:x, :y)\npt = Point.new   # instance constructor; values optional","handlingStrategy":"validation","validationCode":"raise ArgumentError, 'at least one member required' if members.empty?\nKlass = Concurrent::SettableStruct.new(*members)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember SettableStruct.new defines a class; instantiation happens on the generated class","Pass at least one member symbol when defining","For zero-field records, prefer a plain object or Hash"],"tags":["ruby","struct","settable-struct","argument-error","factory-method"],"backgroundTag":"missing-required-argument","analyzedSha":"0b88d5ff75f69b3740c8f0868e76f833cb2fd45d","analyzedAt":"2026-08-21T20:12:56.291Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}