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

Incompatibility of Array#[]= #3411

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

Incompatibility of Array#[]= #3411

ksss opened this issue Jan 22, 2017 · 3 comments

Comments

@ksss
Copy link
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
Copy link
Member

matz commented Jan 23, 2017

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

@matz matz closed this as completed in 5e1d923 Jan 23, 2017
@ksss
Copy link
Contributor Author

ksss commented Jan 23, 2017

Thank you for big deciding

@dabroz
Copy link
Contributor

dabroz commented Jan 23, 2017

cc #3140

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

No branches or pull requests

3 participants