Skip to content

Add parameter and return type restrictions to all stdlib public methods #15334

Open
@nobodywasishere

Description

@nobodywasishere

Discussion

I believe it could be really beneficial if all stdlib public methods (ones intended to be used outside of the compiler itself and not implementation details) had parameter and return type restrictions. There are a few reasons for this:

This can be enforced using the new Typing/* rules that will be added in ameba 1.7.0 as part of #14608.

For certain methods such as Value#==(other) where it can take any type, I propose we use underscores to indicate to the user that this is intended to take any type:

struct Value
  # Current code
  def ==(other)
    false
  end

  # Proposed change for parameters that are intended to take any type
  def ==(other : _)
    false
  end
end

Related:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions