Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected output #1278

Open
aaronmallen opened this issue Oct 11, 2024 · 0 comments
Open

Unexpected output #1278

aaronmallen opened this issue Oct 11, 2024 · 0 comments

Comments

@aaronmallen
Copy link

Given the following signature:

class MethodInjector
  @base: Class
  
  def initialize: (Class base) -> void

  def define_safe_instance_method: [U] (String | Symbol name) { (?) -> U } -> void

  def define_safe_singleton_method: [U] (String | Symbol name) { (?) -> U } -> void

  def safe_alias_instance_method: (String | Symbol method_name, String | Symbol alias_name) -> void

  def safe_alias_singleton_method: (String | Symbol method_name, String | Symbol alias_name) -> void
end

And the following code:

# Inject the defined parameter methods into the base {Constraint::BaseConstraint constraint}.
#
# @return [void]
def inject_parameter_methods!
  injector = MethodInjector.new(@base)
  @data.each_key do |parameter_name|
    # @type self: BaseConstraint
    injector.define_safe_instance_method(parameter_name) { parameters.public_send(parameter_name).value }
    injector.define_safe_instance_method(:"#{parameter_name}=") do |value|
      parameters.public_send(parameter_name).value = value
    end
    injector.define_safe_instance_method(:"#{parameter_name}_default") do
      parameters.public_send(parameter_name).default
    end
  end
end

I get the very verbose output:
steep.log

I'm unsure if this should count as a bug or a question. But without the # @type comment I get:

domainic-type/lib/domainic/type/dsl/parameter_builder.rb:149:67: [error] Type `::Domainic::Type::DSL::ParameterBuilder` does not have method `parameters`
│ Diagnostic ID: Ruby::NoMethod
│
└             injector.define_safe_instance_method(parameter_name) { parameters.public_send(parameter_name).value }
                                                                     ~~~~~~~~~~

domainic-type/lib/domainic/type/dsl/parameter_builder.rb:151:14: [error] Type `::Domainic::Type::DSL::ParameterBuilder` does not have method `parameters`
│ Diagnostic ID: Ruby::NoMethod
│
└               parameters.public_send(parameter_name).value = value
                ~~~~~~~~~~

domainic-type/lib/domainic/type/dsl/parameter_builder.rb:154:14: [error] Type `::Domainic::Type::DSL::ParameterBuilder` does not have method `parameters`
│ Diagnostic ID: Ruby::NoMethod
│
└               parameters.public_send(parameter_name).default
                ~~~~~~~~~~

Detected 3 problems from 1 file

So my question is how should this singature be defined or is this in fact unexpected behavior from steep?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant