You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.
I'm working on adding support for arrow functions (actually it's overstatement, I'm just polishing implementation done by @tuchida in this mozilla/rhino PR) and I've found two problems with 'find()' and 'findIndex()' that were added recently.
First, for code
[1,2,3].find(i=>i%2==0)
Rhino will throw rather funny exception
js: uncaught JavaScript runtime exception: TypeError: org.mozilla.javascript.ArrowFunction@34fe7e0e is not a function, it is function
because it expects to get only instances of NativeFunction as a callback (this check is done only for find() and findIndex()), and here I'm passing an instance of ArrowFunction.
js: uncaught JavaScript runtime exception: TypeError: Array.prototype method called on null or undefined
because again it expects that for find() or findIndex() second argument (thisArg) should never be the same as array itself on which these methods were invoked.
I suppose, both are just mechanical errors, but they were commited with message "more V8 compatibility" and I want to be sure that I'm not breaking anything while removing those checks.
Evgeny put in those changes in order to maintain compatibility with V8 for the new features, but without breaking backward compatibility for existing Rhino users of other functions, so he's probably the best one to address your issue.
Hi,
I'm working on adding support for arrow functions (actually it's overstatement, I'm just polishing implementation done by @tuchida in this mozilla/rhino PR) and I've found two problems with 'find()' and 'findIndex()' that were added recently.
First, for code
Rhino will throw rather funny exception
because it expects to get only instances of
NativeFunction
as a callback (this check is done only forfind()
andfindIndex()
), and here I'm passing an instance ofArrowFunction
.Second, for code
Rhino will throw
because again it expects that for
find()
orfindIndex()
second argument (thisArg
) should never be the same as array itself on which these methods were invoked.I suppose, both are just mechanical errors, but they were commited with message "more V8 compatibility" and I want to be sure that I'm not breaking anything while removing those checks.
//cc @eshepelyuk
The text was updated successfully, but these errors were encountered: