Closed igor-simoes closed 4 years ago
Looks like this is the part of the spec referring to this: https://www.ecma-international.org/ecma-262/8.0/index.html#sec-assignment-operators-runtime-semantics-evaluation (and a few other "runtime semantics" sections)
It seems that if you are defining a function as part of an assignment, and that function has no name (either a function (...) {…}
or (…) => {…}
) then we should be setting the name of the function as the name of the variable it is assigned to. I also see that v8 does the same for var x = {f: function () {}}
, naming the anonymous function f
in that case, but it does not do the same in the case of var x = {}; x.f = function () {}
.
Some further reading of the spec at https://www.ecma-international.org/ecma-262/8.0/index.html#sec-object-initializer-runtime-semantics-propertydefinitionevaluation and https://www.ecma-international.org/ecma-262/8.0/index.html#sec-assignment-operators-runtime-semantics-evaluation suggests that chrome's behavior is probably correct, assuming that the abstract operation GetReferencedName(lref)
doesn't work / returns empty string for x.f
.
This is unfortunately a known issue: https://github.com/Microsoft/ChakraCore/issues/3407. Not sure if we should close it as a dupe, though, because its fairly frustrating and impacts Intl quite a bit.
This should work with -ES6FunctionNameFull. I wonder why we haven't enabled that yet. Is that due to compat break?
There was a compat break issue in 2014 reported by the edge team. At the time a decision was made to hold off on full es6 function name support until other browsers had fully adopted this feature. Its been 4 years now, most browsers have full function.name support. It may be worth a revisit.
This was fixed in master by #6287
Hello everyone, I'm testing some JS engines and I found this inconsistency when getting the name property without function name defined.
Chakra version: 1.9.0.0 OS: Ubuntu 16.04
Steps to reproduce
Expected output
Actual output
baz