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

Update Symbol #1930

Merged
merged 3 commits into from
Jul 25, 2024
Merged

Update Symbol #1930

merged 3 commits into from
Jul 25, 2024

Conversation

sampersand
Copy link
Contributor

@sampersand sampersand commented Jul 13, 2024

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 for Symbol#[]).

core/string.rbs Outdated

interface _MatchAgainst[O, T]
Copy link
Contributor Author

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 Strings, so I've removed the field. However, it is a breaking change, so we might want to hold off on this

Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor Author

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

@sampersand sampersand marked this pull request as ready for review July 13, 2024 02:39
@sampersand sampersand force-pushed the swesterman/24-07-12/symbol branch 2 times, most recently from a2fc0dd to f953dd2 Compare July 19, 2024 01:21
@soutaro soutaro added this to the RBS 3.6 milestone Jul 19, 2024
core/symbol.rbs Outdated Show resolved Hide resolved
core/symbol.rbs Outdated Show resolved Hide resolved
core/symbol.rbs Outdated Show resolved Hide resolved
Copy link
Member

@soutaro soutaro left a 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
Copy link
Member

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.)

Copy link
Contributor Author

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?

Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@soutaro soutaro force-pushed the swesterman/24-07-12/symbol branch from beac527 to 6d56108 Compare July 25, 2024 07:09
@soutaro soutaro force-pushed the swesterman/24-07-12/symbol branch from 6d56108 to 97e5fbc Compare July 25, 2024 07:11
@soutaro soutaro added this pull request to the merge queue Jul 25, 2024
@soutaro
Copy link
Member

soutaro commented Jul 25, 2024

@sampersand Added a few tests at 97e5fbc.

Merged via the queue into ruby:master with commit 34f9880 Jul 25, 2024
19 checks passed
@soutaro soutaro added the Released PRs already included in the released version label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Released PRs already included in the released version
Development

Successfully merging this pull request may close these issues.

3 participants