-
Notifications
You must be signed in to change notification settings - Fork 850
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
Fix some issues with Array.prototype.{find, findIndex} #174
Conversation
Ivan -- first of all, thanks! Second of all, in the last few months we were able to find a new owner of Can you re-submit these changes as a patch to the official Rhino repo: https://github.com/mozilla/rhino The code should be mostly, but not completely, the same. Thanks! On Mon, Apr 20, 2015 at 10:03 PM, Ivan Vyshnevskyi <notifications@github.com
greg brail | apigee https://apigee.com/ | twitter @gbrail |
Congrats @gbrail ! |
Yes, I saw your posts on the mailing list. (Btw, accept my late congratulations! Having motivated maintainer is a must for any OSS project and you're doing great job as far as I can tell from number of releases and PR-s merged. :) I think my "Fixes for apigee#24" confused you (sorry for that) -- this PR is already created in mozilla/rhino repository. |
@sainaen
|
@eshepelyuk Right now there are two problems:
I think fixing single case when these both are in play is not worth of really unexpected "Array.prototype method called on null or undefined" on |
Having 70% of spec implemented is better than having 65% implemented (numbers are arbitrary). So I see no sense of reducing functionality now. Btw I think we can apply the same approach to analyze if |
Sorry, I have to disagree. First of all, it wasn't implementing a spec 5% more compared to this PR, because there's no rule in spec that disallows passing array itself as a |
I'd love to hear (here or on the mailing list) if anyone else has an opinion on this issue about the handling of "this" in these functions. |
Point No 1.First of all I'd like to get us back to the initial point of the discussion that I've raised. And this is not about how to treat I believe we never should reduce implementation scope, especially when it is already included in already released version of Point No 2. How to detect if
|
Sorry, I have to disagree on that (again). I wouldn't call removal of a particular hack that tries to hide one of the Rhino's existing issues for two specific functions, but also adds two new weird issues to them, a reduction of implementation scope. That part of the “scope” just wasn't there in the first place.
I don't see what to discuss here as it's what is required by the spec, isn't it? Anyway, I'd prefer correct full implementation to workaround/hack almost any time, so I'd like to go with the first option. About the order in which fixes should be applied — I think, with changes to how |
Since this code is out there in 1.7.6, I would like to the special "this" handling for "find" and "findIndex" as it is for now. I just added the constant "Context.VERSION_ES6" to the Context class so that we can start to add things that test for "ES6" compliance. Now, we had some debate about what exactly this means, so for the purposes of Rhino, it's going to mean that when set, things that changed in versions of JavaScript up to and including ES6 can be implemented, even if they break compatibility in some cases. Both of you introduced the idea of using the new language level flag to test and add the new behavior of "this" and "thisArg" only when the language level is >= "ES6". I think that we should do that, which would make all the iterative methods on Array consistent. Would either of you have time to make a patch that fixes that (and only that)? In addition, the "do not skip holes in sparse arrays" bit seems orthogonal -- could we just take that patch for now? If you think it makes sense then I can cherry-pick what is in this PR. Finally, I am going to try and do a release very soon, and none of this would make it in, but we can easily do a 1.7.8 or even a 1.8.0 in the near future. |
Hello |
@gbrail, in fact, I would rather proceed with introducing a breaking change for |
I think it depends on what breaking change you are talking about... There is so much Rhino code out in the world, I fear that any breaking On the other hand, if you are just talking about changing the handling of So how about this (a little complicated but probably safe):
Strictly speaking, that feature flag should be "true" for only releases <= On Tue, Jun 16, 2015 at 5:44 PM, Evgeny Shepelyuk notifications@github.com
Greg Brail | apigee https://apigee.com/ | twitter @gbrail |
Introducing feature flag on Context sounds great to me. I would like to go this way. |
OK -- it would make sense to have the "old behavior" flag be true only for On Tue, Jun 16, 2015 at 6:08 PM, Evgeny Shepelyuk notifications@github.com
Greg Brail | apigee https://apigee.com/ | twitter @gbrail |
@gbrail, I think this PR was accidentaly auto-closed by 204, wasn't it ? |
Yes -- I didn't actually merge this one. |
…ex} (except RegExp-s)
…rays According to ES2015 spec, sections 22.1.3.8 and 22.1.3.9, predicate should be called for every k from 0 to length, without checking if property with such index is defined (i.e. even for holes). See section 22.1.3.15 with algorithm for Array.prototype.map, where implementation is required to check HasProperty(O, k) on every iteration.
Hi, I've rebased on current master and removed my changes related to handling Checked with the test262 — this PR fixes 4 tests:
1 about passing built-in function as a callback
Also, I've updated the check that disallows RegExps as callbacks to apply on the new ES6 language level for all |
Btw, you could integrate those test262 cases into |
Yeah, I've used it for testing, but there are still ~168 failing tests and that's to much exclusions to add. I'd rather try to fix some, before doing it manually. |
Just in case: Update: Done. Feel free to merge now. :) |
Rebased and merged the final code. Thanks! |
Great! Thank you. |
Fixes for apigee#24
Done
thisArg
:Also, I've updated tests: fixed those that were not in line with latest ES2015 spec (e.g. about iterating over sparse arrays) and added some cases from Gecko's test suite.
Not done
I wasn't sure I'd have time to fix these in my short “sprint”, as each of them deserves its own separate issue. Additionally, some will require adding new language version or a flag.
thisArg
is not passed,this
inside predicate should be undefined even in non-strict mode:thisObj
set tonull
orundefined
,TypeError
should be thrown:Right now, when
fn.call(null)
is executed,this
forfn
is set to global (as per ES3), but in ES2015ToObject()
should be called on whatever was passed asthis
and it will throw onnull
andundefined
values.//cc @eshepelyuk