mozilla / rhino

Rhino is an open-source implementation of JavaScript written entirely in Java
https://rhino.github.io
Other
4.15k stars 846 forks source link

Support ES2015 function name behavior #1297

Open p-bakker opened 1 year ago

p-bakker commented 1 year ago

ES2015 standardized the behavior of the function.name property. Rhino doesn't comply.

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name, https://2ality.com/2015/09/function-names-es6.html for explanations of expected behavior. See https://tc39.es/ecma262/#sec-setfunctionname and everywhere in the spec where the abstract function operation setFunctionName is used to see the how and when

Debugger implementations would benefit from this, as they would be able to display more meaningful names on each entry in the callstack

Known issues:

Also see #715 for a related case

Some of the scenarios that we currently cannot cover, as they rely on features Rhino doesn't currently support:

rbri commented 1 year ago

will provide a patch for bound functions - because this is simple to fix :-)