Closed Bug 1340147 Opened 7 years ago Closed 7 years ago

Wrong function name assigned to default export function

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: anba, Assigned: anba)

References

Details

(Keywords: triage-deferred)

Attachments

(1 file)

Test case, m.js:
---
import f from './q.js';

print("NAME: ", f.name);
---

q.js:
---
export default function() { };
---


Expected: Prints "NAME: default"
Actual: Prints "NAME: *default*"


Spec: 
14.1.20 Runtime Semantics: InstantiateFunctionObject
Production |FunctionDeclaration : function(FormalParameters){FunctionBody}|, step 3

https://tc39.github.io/ecma262/#sec-function-definitions-runtime-semantics-instantiatefunctionobject
Keywords: triage-deferred
Priority: -- → P3
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=e783125a34fa483b6fc10204d5be15699e793c9d
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED
Attached patch bug1340147.patchSplinter Review
As far as I can tell, it doesn't really matter if the internal binding for default exports is named "*default*" or "default", because both names cannot be used for normal bindings (var, let, const, etc.). That means we can simply switch the name of the internal binding from "*default*" (the name used in the spec) to "default" without breaking anything. And now the existing code to name functions (and classes) just works (TM) and default exported functions and classes will be correctly named "default" instead of "*default*".

Additionally I've fixed another bug which was revealed when I enabled the test262 tests: We didn't implement naming anonymous functions in default export expressions <https://tc39.github.io/ecma262/#sec-exports-runtime-semantics-evaluation>.
Attachment #8930043 - Flags: review?(jcoppeard)
Comment on attachment 8930043 [details] [diff] [review]
bug1340147.patch

Review of attachment 8930043 [details] [diff] [review]:
-----------------------------------------------------------------

Thank you for the fix, this is great.
Attachment #8930043 - Flags: review?(jcoppeard) → review+
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/65d596a31eb9
Correctly name default function exports as "default". r=jonco
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/65d596a31eb9
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: