ruby / rbs

Type Signature for Ruby
Other
1.96k stars 215 forks source link

Support Range#step behavior change in Ruby 3.4 #1958

Open zverok opened 3 months ago

zverok commented 3 months ago

This is a PR to support this change in Ruby: https://github.com/ruby/ruby/pull/7444 (the design is approved by Matz, and the code itself is approved by the Ruby core team).

I am not sure how this actually should be addressed, so I will be thankful for any advice.

Basically, the essence of the change is that:

So, my questions are:

  1. How to describe that in RBS syntax?
  2. How to adjust RBS core/range.rbs to specify that the signature was changed between 3.3 and 3.4?
  3. How to proceed with those two PRs (into Ruby itself and into rbs)?

Please advise :pray:

ParadoxV5 commented 3 months ago
  1. How to describe that in RBS syntax?

It would be using an interface that’s along the lines of

interface _Addable[T]
  def +: (T other) -> T
end

@sampersand has ongoing interest in interfaces [P.S. and Ruby core RBSs in general] like this; it’d be conveient to coördinate this addition with him.

  1. How to adjust RBS core/range.rbs to specify that the signature was changed between 3.3 and 3.4?

RBS files doesn’t have Ruby versioning currently and the latest versions only track the latest Ruby release. However, release notes include statements on updating Ruby version and links to PRs.

  1. How to proceed with those two PRs (into Ruby itself and into rbs)?

Soutaro released RBS 3.4 nearing Ruby 3.3’s release as the new bundled version.

I say, proceed with the Ruby side first. RBSs in this repo (or at least those for the Ruby core) also include a copy of Ruby’s docs; so if the Ruby doc mentions using #+ during Ruby 3.4’s preview, it gives Soutaro time to update the docs here for an accompanying RBS release.

zverok commented 3 months ago

I say, proceed with the Ruby side first.

I see. My concern here is that due to this “incompatibility”, the core Ruby CI is red (the test-bundled-gems task), therefore if I’ll merge it into the main branch, then it would be red for everybody till the rbs would be adjusted.

So I am looking for a way to mitigate it.

soutaro commented 3 months ago

@zverok Thank you for letting us know the change.

How about using rbs_skip_tests in Ruby repo to put your change there? You can skip tests of RBS gem in Ruby repo, and then we can update the RBS tests.

zverok commented 3 months ago

@soutaro Thank you for your help! :pray:

I used rbs_skip_tests solution, and now the PR is merged :tada: