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

Incompatibility of Array#[]= #3411

Closed
ksss opened this Issue Jan 22, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@ksss
Contributor

ksss commented Jan 22, 2017

a = []
a[3..4] = 1
p a
#=> CRuby: [nil, nil, nil, 1]
#=> mruby: []
a = []
a[-1..-1] = 1
#=> CRuby: RangeError: -1..-1 out of range
#=> mruby: return 1 and `a` is `[]`

I think, The cause is incompatibility of mruby's mrb_range_beg_len and CRuby's rb_range_beg_len

if (mrb_range_beg_len(mrb, v1, &i, &len, RARRAY_LEN(self))) {

https://github.com/ruby/ruby/blob/78b95b49f8715a4782f5b9bdc4c163e445cdc303/array.c#L1740

I think, We'll need another function same as mrb_range_beg_len if we want to fix this issue and expect no break backward compatibility.

@matz

This comment has been minimized.

Show comment
Hide comment
@matz

matz Jan 23, 2017

Member

The difference is not intended, so I will fix this (and break compatibility).

Member

matz commented Jan 23, 2017

The difference is not intended, so I will fix this (and break compatibility).

@matz matz closed this in 5e1d923 Jan 23, 2017

@ksss

This comment has been minimized.

Show comment
Hide comment
@ksss

ksss Jan 23, 2017

Contributor

Thank you for big deciding

Contributor

ksss commented Jan 23, 2017

Thank you for big deciding

matz added a commit that referenced this issue Jan 23, 2017

@dabroz

This comment has been minimized.

Show comment
Hide comment
@dabroz

dabroz Jan 23, 2017

Contributor

cc #3140

Contributor

dabroz commented Jan 23, 2017

cc #3140

matz added a commit that referenced this issue Jan 23, 2017

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