-
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
Update Symbol #1930
Update Symbol #1930
Conversation
core/string.rbs
Outdated
|
||
interface _MatchAgainst[O, T] |
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 didnt make much sense to have an O
field here, as it's only ever being matched against String
s, so I've removed the field. However, it is a breaking change, so we might want to hold off on this
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.
Changing from O = self
to String
loses type narrowing.
Having a generic #=~
(with both LHS and RHS type variables) is also fine for #1638.
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.
Resolved by reverting this
@@ -469,6 +469,4 @@ class Symbol | |||
| (:ascii | :lithuanian | :turkic) -> Symbol | |||
| (:lithuanian, :turkic) -> Symbol | |||
| (:turkic, :lithuanian) -> Symbol | |||
|
|||
def clone: (?freeze: true?) -> 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.
Not actually defined in Symbol
a2fc0dd
to
f953dd2
Compare
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 untyped
version should return for the case of the argument is a Symbol
.
a = [1, :foo, "bar"].sample # => a: Integer | Symbol | String | nil
:foo <=> a # untyped overload is selected, but the actual value may be a Symbol
@@ -176,7 +174,7 @@ class Symbol | |||
# variables; see String#=~. | |||
# | |||
def =~: (Regexp regex) -> Integer? | |||
| [T] (String::_MatchAgainst[self, T] object) -> T | |||
| [T] (String::_MatchAgainst[String, T] object) -> T |
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.
[Optional] Wondering if you can add a test to confirm the _MatchAgains
generic interface works correctly with Steep. (in test/typecheck/_MatchAgainst
or somewhere.)
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.
Do we have any of these as examples to base it off of?
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.
👍
beac527
to
6d56108
Compare
6d56108
to
97e5fbc
Compare
@sampersand Added a few tests at 97e5fbc. |
This pr updates
Symbol
.There wasn't actually a ton to do; it was mostly marking things as aliases, and copying signatures over from
String
(eg forSymbol#[]
).