oracle / truffleruby

A high performance implementation of the Ruby programming language, built on GraalVM.
https://www.graalvm.org/ruby/
Other
3.02k stars 185 forks source link

MatchData#values_at drops nil with range #2783

Closed djberg96 closed 1 year ago

djberg96 commented 1 year ago

truffleruby 22.3.0, like ruby 3.0.3, GraalVM CE Native [x86_64-darwin]

The MatchData#values_at method appears to be dropping nil when a range is larger than the number of matched values:

matchdata = /\w+/.match('hello')
p matchdata.values_at(0, 1) # => ["hello", nil] # ok
p matchdata.values_at(0..1) # => ["hello"]      # oops, expected ["hello", nil]
andrykonchin commented 1 year ago

Thank you for reporting!

The issue can be reproduced easily. Will work on a fix.

andrykonchin commented 1 year ago

Fixed in 2596a2316f73e5e938dfb0d1f7e6ad6cbb31e3d1