Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upInconsistencies in semantics of default module exports. #586
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
allenwb
Jun 2, 2016
Member
This won't:
export default (class {}); // AssignmentExpression
It will. This form is handled by the ExportDeclaration : export default AssignmentExpression ; algorithm in 15.2.3.11. Because IsAnonymousFunctionDefinition will return true for an AssignmentExression that is an anonymous class declaration.
This won't:
This looks like a spec. bug to me. The HoistableDeclaration case looks like it should have a step similar to step 4 of the ClassDelaration case of 15.2.3.11.
I can't recall any reason why I would have intentionally left it out for the HoistableDeclaration case.
It will. This form is handled by the ExportDeclaration : export default AssignmentExpression ; algorithm in 15.2.3.11. Because IsAnonymousFunctionDefinition will return true for an AssignmentExression that is an anonymous class declaration.
This looks like a spec. bug to me. The HoistableDeclaration case looks like it should have a step similar to step 4 of the ClassDelaration case of 15.2.3.11. I can't recall any reason why I would have intentionally left it out for the HoistableDeclaration case. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
GeorgNeis
Jun 6, 2016
Contributor
Thanks for pointing out my misunderstanding regarding the first part. Regarding the second part, maybe I'm wrong as well: I just found InstantiateFunctionObject, which is called in 15.2.1.16.4 (ModuleDeclarationInstantiation) and sets the "name" property to "default".
|
Thanks for pointing out my misunderstanding regarding the first part. Regarding the second part, maybe I'm wrong as well: I just found InstantiateFunctionObject, which is called in 15.2.1.16.4 (ModuleDeclarationInstantiation) and sets the "name" property to "default". |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
I guess this can be closed. I no longer think there is a bug. |
GeorgNeis commentedJun 2, 2016
In 15.2.3.11 (Runtime Semantics: Evaluation), the evaluation of default exports
sets the exported object's "name" property to "default" in some cases. Unless I'm
misreading something, this is done in an inconsistent way.
This will set the class's .name to "default":
export default class {} // ClassDeclarationThis won't:
export default (class {}); // AssignmentExpressionFor functions, the situtation seems reversed:
This will set the function's .name to "default":
export default (function() {}); // AssignmentExpressionThis won't:
export default function() {} // HoistableDeclarationIs this intended?