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

Implement beginless range #2155

Closed
wants to merge 20 commits into from
Closed

Conversation

LillianZ
Copy link
Contributor

@LillianZ LillianZ commented Nov 13, 2020

Starting to implement beginless ranges for Ruby 2.7 compatibility #2004

So far:
Implemented or added specs for Range#{new, bsearch, count, each, equal_value, first, inspect, max, min, size} regarding beginless range compatibility
Implemented or added specs for Array#{[], []=, slice, slice!, to_a, fill, values_at} regarding beginless range compatibility

To do:
Range#cover?/include/===
some or all of Range#{entires, eql?, hash, last, member?, minmax, step/%, to_s}
Methods outside of Array and Range, such as String methods.

Shopify#1

@LillianZ LillianZ force-pushed the beginlessRange branch 4 times, most recently from 598038c to 1d5401d Compare November 16, 2020 22:56
@eregon eregon requested a review from norswap November 17, 2020 12:15
@eregon
Copy link
Member

eregon commented Nov 17, 2020

@norswap Could you review this one?

Looks good to me :)

@LillianZ
Copy link
Contributor Author

Is jt format a known issue right now?

@norswap
Copy link
Contributor

norswap commented Nov 17, 2020

@LillianZ Do you mean the Eclipse error where it can't find libjvm.dylib on macOS? Then yes. The quickfix is to:

OPENJDK_VERSION=openjdk1.8.0_272-jvmci-20.3-b04 # adapt
cd ~/.mx/cache/truffleruby/$OPENJDK_VERSION/Contents/MacOS/
rm libjli.dylib
ln -s ../Home/jre/lib/jli/libjli.dylib libjli.dylib
cd -

The problem has been known for some time, but it's in limbo as it requires digging into the OpenJDK build process. It's fixed on the GraalVM image builds however.

@LillianZ
Copy link
Contributor Author

LillianZ commented Nov 17, 2020

Got it, thank you! I misunderstood the error logs. Force-pushed some spacing for lint.

Copy link
Contributor

@norswap norswap left a comment

Choose a reason for hiding this comment

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

Looks good to me so far!

Another place I remember I had to handle endless ranges explicitly was StringNodes#GetIndexNode.

src/main/ruby/truffleruby/core/range.rb Outdated Show resolved Hide resolved
@LillianZ LillianZ force-pushed the beginlessRange branch 2 times, most recently from b22b033 to 304493f Compare November 17, 2020 20:11
@graalvmbot
Copy link
Collaborator

Hello LillianZ, thanks for contributing a PR to our project!

We use the Oracle Contributor Agreement to make the copyright of contributions clear. We don't have a record of you having signed this yet, based on your email address LillianZ -(at)- users -(dot)- noreply -(dot)- github -(dot)- com. You can sign it at that link.

If you think you've already signed it, please comment below and we'll check.

@eregon
Copy link
Member

eregon commented Nov 23, 2020

@LillianZ I can add that email to the list, but it would be better to rebase instead of merge to have a clean history.

@graalvmbot
Copy link
Collaborator

LillianZ has signed the Oracle Contributor Agreement (based on email address LillianZ -(at)- users -(dot)- noreply -(dot)- github -(dot)- com) so can contribute to this repository.

@LillianZ
Copy link
Contributor Author

Sorry, a conflict appeared online not appearing locally, and trying to resolve it caused a merge. I have been trying to rebase.

@eregon
Copy link
Member

eregon commented Nov 23, 2020

FWIW, the GitHub UI often thinks there are conflicts in CHANGELOG.md, but actually there isn't due to the union merge strategy which never conflicts. Best is to just ignore those, because there are no actual conflicts.

@LillianZ
Copy link
Contributor Author

LillianZ commented Nov 23, 2020

To confirm: it's okay ignore when GitHub UI complains about a conflict (at least in CHANGELOG) because it's something you can fix?

@LillianZ
Copy link
Contributor Author

LillianZ commented Nov 25, 2020

I am slightly concerned that 2.6 specs have been running for 3 hours, but they passed locally so I'm not sure what to do.

@chrisseaton
Copy link
Collaborator

Looks broken - it's not running at all. CI is hard.

@LillianZ
Copy link
Contributor Author

Thanks for checking! I fixed my commit message to get CI to rerun.

@eregon
Copy link
Member

eregon commented Nov 26, 2020

Most likely this indicates a spec getting stuck when run on MRI 2.6.6.
Unfortunately it seems GitHub Actions stops the job without any signal or anything to get a chance to show a backtrace.
Locally I could reproduce with:

$ mspec --timeout 60 .
$ ruby /home/eregon/code/mspec/bin/mspec-run --timeout 60 .
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
[\ | ===============   39%                    | 00:00:33]      0F      0E 
Range#count returns Infinity for endless ranges without arguments or blocks
Example took longer than the configured timeout of 60.0s

So I'll add the --timeout option, that way we'll see which spec got stuck in CI.

@chrisseaton
Copy link
Collaborator

Looks like it's generating some kind of infinite string or something. We're investigating.

@LillianZ
Copy link
Contributor Author

It's fixed! For some reason I didn't realize the specs breaking on CRuby 2.6 => fix 2.6 specs.

ruby_version_is "2.7" do
it "works with beginless ranges" do
[1, 2, 3, 4].fill('x', eval("(nil..2)")).should == ["x", "x", "x", 4]
[1, 2, 3, 4].fill(eval("(nil...2)")) { |x| x + 2 }.should == [2, 3, 3, 4]
Copy link
Member

@eregon eregon Nov 27, 2020

Choose a reason for hiding this comment

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

Could you remove the extra nils here? Also happens in other specs.

@norswap
Copy link
Contributor

norswap commented Nov 27, 2020

Failures:

  • Primitive.infect was removed as taint checking is deprecated in 2.7 and the various tainting methods become no-ops
  • The Range#max spec is tagged for Ruby 2.7.2, but the fix to that upstream bug is here and it seems to be on a branch tagged for 3.0.

@LillianZ
Copy link
Contributor Author

Woot! everything's finally passing! sorry for the delay, and thanks for all the tips; I found the range#max patch in ruby-lang and definitely would not have known to go looking in github!

@eregon eregon added the in-ci The PR is being tested in CI. Do not push new commits. label Dec 1, 2020
graalvmbot pushed a commit that referenced this pull request Dec 1, 2020
PullRequest: truffleruby/2226
@norswap
Copy link
Contributor

norswap commented Dec 1, 2020

Merged! Congrats 👍

@norswap norswap closed this Dec 1, 2020
@norswap norswap removed the in-ci The PR is being tested in CI. Do not push new commits. label Dec 1, 2020
@LillianZ LillianZ deleted the beginlessRange branch December 2, 2020 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants