-
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
A tiny followup for #1641’s oopsies #1672
Conversation
re-ping: #1641 |
test `(nil, &nil) -> String`
@@ -1349,7 +1349,7 @@ class String | |||
# modification made, `self` otherwise. | |||
# | |||
def chomp!: (nil) -> nil | |||
| (?string? separator) -> self? |
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.
This case is necessary.
Passing a node of type String?
will be a type error without the ?
.
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.
This is a problem with the type checkers unable to break string
and nil
from string?
to different paths and then merge them back to self? | nil
i.e. self?
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.
It may be true. Type checkers can do more about this.
But at least for now, RBS is for static type checking and having string?
is more common for static type checking (I believe.)
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.
But at least for now
How about this: I will revert it for now, but we should also remind type checker maintainers about these sort of cases.
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.
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.
Revert the type of chomp!
. 🙏
This PR now only updates `scrub`
No comments? Then how did L648 pass CI Line 648 in a4681af
|
@ParadoxV5 You uncovered another bug. 🐞 https://github.com/ruby/rbs/blob/master/lib/rbs/writer.rb#L224 writes lines, from the beginning of Having a comment line between the two overloads would pass CI. def chomp!: (nil) -> nil
# | (?string separator) -> self? # https://github.com/ruby/rbs/pull/1672#discussion_r1423324796
| (?string? separator) -> self?
|
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.
👍
chomp!
: The?
suffix in(?string? separator)
is already covered by(nil)
.scrub
: Just likescrub!
,scrub(nil, &nil)
is a thing.Question: What shall the convension around
?Regexp | string | nil
vs.?Regexp | string?
be?