-
Notifications
You must be signed in to change notification settings - Fork 216
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
Add pp in stdlib #1545
Add pp in stdlib #1545
Conversation
It seems there might be an issue with the # original
def seplist: (untyped list, ?(^() -> void)? sep, ?interned iter_method) { (*untyped, **untyped) -> void } -> void
# RBS::Writer
def seplist: (untyped list, ?^() -> void? sep, ?interned iter_method) { (*untyped, **untyped) -> void } -> void The following RBS is interpreted as next follows: ^() -> void? ^() -> (void | nil) |
core/kernel.rbs
Outdated
@@ -1269,7 +1269,7 @@ module Kernel : BasicObject | |||
# pp returns argument(s). | |||
# | |||
def self?.pp: [T] (T arg0) -> T | |||
| (untyped, untyped, *untyped) -> Array[untyped] | |||
| (untyped, *untyped) -> Array[untyped] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second untyped
was actually to skip the first overload if one argument is given.
Not sure if removing it causes another type error or not. (It won't on Steep.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see, that's what it meant.
The original definition is as follows:
module Kernel
def pp(*objs)
objs.each {|obj|
PP.pp(obj)
}
objs.size <= 1 ? objs.first : objs
end
module_function :pp
end
I became concerned because Steep reported the following:
The method parameter has different kind from the declaration `[T(353)(354)] (?untyped, ?untyped, *untyped) -> (T(353)(354) | ::Array[untyped] | nil)`(Ruby::DifferentMethodParameterKind)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ksss I mean the use-site. It depends on how the overloading is resolved. (Steep uses the first matching one, so passing one argument to pp
resolves to the first overload anyways.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I'll revert this commit later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@ksss I found that |
@soutaro Thank you. Certainly, that's true. I will move it to the core soon. |
@soutaro If we move It seems that Moreover, the signature for Lines 1262 to 1272 in 32cd6c9
I believe it might be better not to add |
@ksss Got it.
Clicking the merge button. 👍 |
I added the type for the standard library
pp
since it was missing.I am performing the following tasks also:
Kernel#pp
.RBS::Types::Optional#to_s
with Proc