rbs icon indicating copy to clipboard operation
rbs copied to clipboard

Support Range#step behavior change in Ruby 3.4

Open zverok opened this issue 1 year ago • 4 comments

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:

  • Before Ruby 3.4, Ruby#step’s type signature was step(Int step?)
  • After the linked PR, the signature would become step(Addable step), with Addable being such that Range#begin + step will work and produce the next value.

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:

zverok avatar Aug 10 '24 18:08 zverok

  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.

ParadoxV5 avatar Aug 10 '24 19:08 ParadoxV5

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.

zverok avatar Aug 11 '24 17:08 zverok

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

soutaro avatar Aug 13 '24 01:08 soutaro

@soutaro Thank you for your help! :pray:

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

zverok avatar Aug 18 '24 18:08 zverok

I'm taking over this PR.

soutaro avatar Dec 19 '24 02:12 soutaro