chanzuckerberg / sorbet-rails

A set of tools to make the Sorbet typechecker work with Ruby on Rails seamlessly.
MIT License
638 stars 84 forks source link

Type check errors in generated RBI files #558

Open dominicgoulet opened 1 year ago

dominicgoulet commented 1 year ago

Describe the bug: On a freshly created Rails 7 API, when I setup Sorbet and Sorbet-Rails, there are a lot of errors detected by srb tc related to the generated RBI files:

sorbet/rbi/gems/sorbet-rails@0.7.34.rbi:15: Duplicate type member Elem https://srb.help/4011
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/type_assert.rbi:7: Also defined here
     7 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/sorbet-rails@0.7.34.rbi:594: Duplicate type member Elem https://srb.help/4011
     594 |  Elem = type_member
            ^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/type_assert.rbi:23: Also defined here
    23 |  Elem = type_member
          ^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/activestorage@7.0.4.3.rbi:1890: Method ActiveStorage::Attachment.with_all_variant_records redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
    1890 |    def with_all_variant_records(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/active_storage/attachment.rbi:72: Previous definition
    72 |  def self.with_all_variant_records(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/activestorage@7.0.4.3.rbi:2083: Method ActiveStorage::Blob.unattached redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
    2083 |    def unattached(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/active_storage/blob.rbi:34: Previous definition
    34 |  def self.unattached(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/activestorage@7.0.4.3.rbi:2086: Method ActiveStorage::Blob.with_attached_preview_image redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
    2086 |    def with_attached_preview_image(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/active_storage/blob.rbi:37: Previous definition
    37 |  def self.with_attached_preview_image(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/activestorage@7.0.4.3.rbi:3238: Method ActiveStorage::VariantRecord.with_attached_image redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
    3238 |    def with_attached_image(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/active_storage/variant_record.rbi:34: Previous definition
    34 |  def self.with_attached_image(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/actiontext@7.0.4.3.rbi:1025: Method ActionText::RichText.with_attached_embeds redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
    1025 |    def with_attached_embeds(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/action_text/rich_text.rbi:34: Previous definition
    34 |  def self.with_attached_embeds(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:7: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
     7 |  sig { params(args: T.untyped).returns(Elem) }
                                                ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:10: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    10 |  sig { params(args: T.untyped).returns(T.nilable(Elem)) }
                                                          ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:13: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    13 |  sig { params(args: T.untyped).returns(Elem) }
                                                ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:16: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    16 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                                          ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:16: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    16 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                     ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:19: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    19 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                                          ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:19: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    19 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                     ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:22: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    22 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                                          ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:22: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    22 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                     ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:25: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    25 |  sig { returns(T.nilable(Elem)) }
                                  ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:28: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    28 |  sig { returns(Elem) }
                        ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:31: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    31 |  sig { returns(T.nilable(Elem)) }
                                  ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:34: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    34 |  sig { returns(Elem) }
                        ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:37: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    37 |  sig { returns(T.nilable(Elem)) }
                                  ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:40: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    40 |  sig { returns(Elem) }
                        ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:43: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    43 |  sig { returns(T.nilable(Elem)) }
                                  ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:46: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    46 |  sig { returns(Elem) }
                        ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:49: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    49 |  sig { returns(T.nilable(Elem)) }
                                  ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:52: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    52 |  sig { returns(Elem) }
                        ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:55: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    55 |  sig { returns(T.nilable(Elem)) }
                                  ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:58: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    58 |  sig { returns(Elem) }
                        ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:61: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    61 |  sig { returns(T.nilable(Elem)) }
                                  ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:64: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    64 |  sig { returns(Elem) }
                        ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:67: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    67 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                                          ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:67: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    67 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                     ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:70: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    70 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                                          ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:70: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    70 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                     ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:73: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    73 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                                          ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:73: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    73 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                     ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:76: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    76 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                                          ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:76: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    76 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                     ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:79: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    79 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                                          ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:79: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    79 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                     ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:82: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    82 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                                          ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:82: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    82 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                     ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:85: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    85 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                                          ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:85: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    85 |  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
                                                                                     ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:95: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    95 |    ).returns(T::Enumerator[Elem])
                                    ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:94: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
    94 |      block: T.nilable(T.proc.params(e: Elem).void)
                                                ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:106: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
     106 |    ).returns(T::Enumerator[T::Array[Elem]])
                                               ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:105: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
     105 |      block: T.nilable(T.proc.params(e: T::Array[Elem]).void)
                                                           ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:110: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
     110 |  sig { params(block: T.nilable(T.proc.params(e: Elem).returns(T.nilable(T::Boolean)))).returns(T::Boolean) }
                                                           ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:113: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
     113 |  sig { params(block: T.nilable(T.proc.params(e: Elem).returns(T.nilable(T::Boolean)))).returns(T::Boolean) }
                                                           ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:116: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
     116 |  sig { params(block: T.nilable(T.proc.params(e: Elem).returns(T.nilable(T::Boolean)))).returns(T::Boolean) }
                                                           ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:119: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
     119 |  sig { params(block: T.nilable(T.proc.params(e: Elem).returns(T.nilable(T::Boolean)))).returns(T::Boolean) }
                                                           ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:125: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
     125 |  sig { override.params(block: T.proc.params(e: Elem).void).returns(T::Array[Elem]) }
                                                                                       ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:125: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
     125 |  sig { override.params(block: T.proc.params(e: Elem).void).returns(T::Array[Elem]) }
                                                          ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:128: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
     128 |  sig { params(level: T.nilable(Integer)).returns(T::Array[Elem]) }
                                                                     ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:131: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
     131 |  sig { returns(T::Array[Elem]) }
                                   ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:4: Type Elem declared by parent Enumerable must be re-declared in ActiveRecord::Relation https://srb.help/5036
     4 |class ActiveRecord::Relation
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Elem declared in parent here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/active_record_relation.rbi:134: type_member type Enumerable::Elem used outside of the class definition https://srb.help/5072
     134 |  sig { type_parameters(:U).params(blk: T.proc.params(arg0: Elem).returns(T.type_parameter(:U))).returns(T::Array[T.type_parameter(:U)]) }
                                                                      ^^^^
    https://github.com/sorbet/sorbet/tree/687cdf16e6f3bfcfa790d62d68b730db5aa62ac2/rbi/core/enumerable.rbi#L15: Enumerable::Elem defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/type_assert.rbi:7: Duplicate type member Elem https://srb.help/4011
     7 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rbi/gems/sorbet-rails@0.7.34.rbi:15: Also defined here
    15 |  Elem = type_member(:out)
          ^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rails-rbi/type_assert.rbi:23: Duplicate type member Elem https://srb.help/4011
    23 |  Elem = type_member
          ^^^^^^^^^^^^^^^^^^
    sorbet/rbi/gems/sorbet-rails@0.7.34.rbi:594: Also defined here
     594 |  Elem = type_member
            ^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/actionmailbox@7.0.4.3.rbi:377: Method ActionMailbox::InboundEmail.bounced redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
     377 |    def bounced(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/action_mailbox/inbound_email.rbi:70: Previous definition
    70 |  def self.bounced(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/actionmailbox@7.0.4.3.rbi:383: Method ActionMailbox::InboundEmail.delivered redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
     383 |    def delivered(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/action_mailbox/inbound_email.rbi:73: Previous definition
    73 |  def self.delivered(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/actionmailbox@7.0.4.3.rbi:386: Method ActionMailbox::InboundEmail.failed redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
     386 |    def failed(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/action_mailbox/inbound_email.rbi:76: Previous definition
    76 |  def self.failed(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/actionmailbox@7.0.4.3.rbi:389: Method ActionMailbox::InboundEmail.not_bounced redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
     389 |    def not_bounced(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/action_mailbox/inbound_email.rbi:79: Previous definition
    79 |  def self.not_bounced(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/actionmailbox@7.0.4.3.rbi:392: Method ActionMailbox::InboundEmail.not_delivered redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
     392 |    def not_delivered(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/action_mailbox/inbound_email.rbi:82: Previous definition
    82 |  def self.not_delivered(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/actionmailbox@7.0.4.3.rbi:395: Method ActionMailbox::InboundEmail.not_failed redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
     395 |    def not_failed(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/action_mailbox/inbound_email.rbi:85: Previous definition
    85 |  def self.not_failed(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/actionmailbox@7.0.4.3.rbi:398: Method ActionMailbox::InboundEmail.not_pending redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
     398 |    def not_pending(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/action_mailbox/inbound_email.rbi:88: Previous definition
    88 |  def self.not_pending(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/actionmailbox@7.0.4.3.rbi:401: Method ActionMailbox::InboundEmail.not_processing redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
     401 |    def not_processing(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/action_mailbox/inbound_email.rbi:91: Previous definition
    91 |  def self.not_processing(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/actionmailbox@7.0.4.3.rbi:404: Method ActionMailbox::InboundEmail.pending redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
     404 |    def pending(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/action_mailbox/inbound_email.rbi:94: Previous definition
    94 |  def self.pending(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/actionmailbox@7.0.4.3.rbi:407: Method ActionMailbox::InboundEmail.processing redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
     407 |    def processing(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/action_mailbox/inbound_email.rbi:97: Previous definition
    97 |  def self.processing(*args); end
          ^^^^^^^^^^^^^^^^^^^^^^^^^^

sorbet/rbi/gems/actionmailbox@7.0.4.3.rbi:413: Method ActionMailbox::InboundEmail.with_attached_raw_email redefined without matching argument count. Expected: 1, got: 2 https://srb.help/4010
     413 |    def with_attached_raw_email(*args, **_arg1); end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rails-rbi/models/action_mailbox/inbound_email.rbi:100: Previous definition
     100 |  def self.with_attached_raw_email(*args); end

Steps to reproduce: Use this gemfile on a freshly created Rails 7 API:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.1.2'

# Core
gem 'jwt', '2.7.0'
gem 'pg', '1.5.3'
gem 'puma', '6.2.2'
gem 'rack-cors', '2.0.1'
gem 'rails', '7.0.4.3'

# Security
gem 'bcrypt', '3.1.18'

# JSON
gem 'alba', '2.3.0'
gem 'oj', '3.14.3'

# Sorbet
gem 'sorbet-rails', '0.7.34'
gem 'sorbet-runtime', '0.5.10801'

# Others
gem 'bootsnap', '1.16.0', require: false

group :development, :test do
  gem 'annotate'
  gem 'guard'
  gem 'guard-minitest'
  gem 'rubocop', require: false
  gem 'sorbet'
  gem 'tapioca', require: false
end

group :test do
  gem 'database_cleaner-active_record'
  gem 'simplecov', require: false
end

Expected behavior: No errors should be displayed.

Versions:

xjose97x commented 1 year ago

Ran into the same issue. Has anyone been able to find a workaround?

dominicgoulet commented 1 year ago

@xjose97x Yes, the workaround is just to not use sorbet-rails. You can get everything working with just sorbet. I ended up using sorbet-rails only for TypedParams, but you could definitely just extract that bit.