Skip to content

Ruby::MethodDefinitionMissing with attr_reader #1036

Open
@lloeki

Description

@lloeki
  • attr_reader foo: untyped in RBS defines the signature for the method #foo as would def foo: () -> untyped
  • with Steep::Diagnostic::Ruby::MethodDefinitionMissing Steep expects the method #foo from the above
  • attr_reader in Ruby defines the method #foo yet Steep can't find it, even though both .rb and .rbsuseattr_reader` semantics

Expected result:

  • attr_reader foo: untyped should be able to find attr_reader-defined methods
  • Arguably def foo: () -> untyped + @foo: untyped should also work with and find attr_reader :foo
  • Same for attr_writer and attr_accessor and #foo=

Actual result:

# foo.rb
class Foo
  attr_reader :foo
end
# foo.rbs
class Foo
  attr_reader foo: untyped
end
# Steepfile
target :lib do
  configure_code_diagnostics do |hash|
    hash[Steep::Diagnostic::Ruby::MethodDefinitionMissing] = :error
  end

  check '.'
  signature '.'
end
$ bundle exec steep check foo.rb
foo.rb:1:6: [error] Cannot find implementation of method `::Foo#foo`
│ Diagnostic ID: Ruby::MethodDefinitionMissing
│
└ class Foo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions