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

Struct#values_at should raise IndexError if out of bounds #2773

Closed
djberg96 opened this issue Nov 8, 2022 · 2 comments
Closed

Struct#values_at should raise IndexError if out of bounds #2773

djberg96 opened this issue Nov 8, 2022 · 2 comments

Comments

@djberg96
Copy link
Contributor

djberg96 commented Nov 8, 2022

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

As per the title, MRI raises an IndexError if the value provided to the values_at method is out of bounds. Currently TruffleRuby returns [nil].

Struct.new('ValuesAt', :a, :b, :c, :d, :e, :f)
struct = Struct::ValuesAt.new(1, 2, 3, 4, 5)
p struct.values_at(99) # => Should raise "offset 99 too large for struct(size:6) (IndexError)"
@eregon
Copy link
Member

eregon commented Nov 8, 2022

Thanks for the report, this should be fairly easy to fix in https://github.com/oracle/truffleruby/blob/master/src/main/ruby/truffleruby/core/struct.rb

@andrykonchin
Copy link
Member

Fixed in 7adb9cb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants