Closed
Bug 1320993
Opened 8 years ago
Closed 8 years ago
Assertion failure: cls.names() with default export and unnamed class expression
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla53
Tracking | Status | |
---|---|---|
firefox53 | --- | fixed |
People
(Reporter: anba, Assigned: jonco)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
patch
|
shu
:
review+
|
Details | Diff | Splinter Review |
Test case:
---
parseModule("export default (class {})");
---
Asserts with:
---
Assertion failure: cls.names(), at /home/andre/git/mozilla-central/js/src/builtin/ModuleObject.cpp:1181
---
Back trace:
---
#0 0x000000000059ec06 in js::ModuleBuilder::processExport (this=0x7fffffffb200, pn=0x7ffff69fc110) at /home/andre/git/mozilla-central/js/src/builtin/ModuleObject.cpp:1181
#1 0x00000000004bfda3 in js::frontend::Parser<js::frontend::FullParseHandler>::exportDeclaration (this=0x7fffffffbf00)
at /home/andre/git/mozilla-central/js/src/frontend/Parser.cpp:5142
#2 0x00000000004d1ddc in js::frontend::Parser<js::frontend::FullParseHandler>::statementListItem (this=0x7fffffffbf00, yieldHandling=js::frontend::YieldIsKeyword,
canHaveDirectives=true) at /home/andre/git/mozilla-central/js/src/frontend/Parser.cpp:7182
#3 0x00000000004d397e in js::frontend::Parser<js::frontend::FullParseHandler>::statementList (this=0x7fffffffbf00, yieldHandling=js::frontend::YieldIsKeyword)
at /home/andre/git/mozilla-central/js/src/frontend/Parser.cpp:3836
#4 0x00000000004bb35b in js::frontend::Parser<js::frontend::FullParseHandler>::moduleBody (this=0x7fffffffbf00, modulesc=0x7fffffffb180)
at /home/andre/git/mozilla-central/js/src/frontend/Parser.cpp:2021
#5 0x0000000000ce84bf in BytecodeCompiler::compileModule (this=0x7fffffffb8b0) at /home/andre/git/mozilla-central/js/src/frontend/BytecodeCompiler.cpp:397
#6 0x0000000000ce9334 in js::frontend::CompileModule (cx=0x7ffff6965000, optionsInput=..., srcBuf=..., alloc=..., sourceObjectOut=0x0)
at /home/andre/git/mozilla-central/js/src/frontend/BytecodeCompiler.cpp:598
#7 0x0000000000ce9419 in js::frontend::CompileModule (cx=0x7ffff6965000, options=..., srcBuf=...) at /home/andre/git/mozilla-central/js/src/frontend/BytecodeCompiler.cpp:609
#8 0x0000000000448d29 in ParseModule (cx=0x7ffff6965000, argc=1, vp=0x7ffff151e090) at /home/andre/git/mozilla-central/js/src/shell/js.cpp:3998
...
---
And possibly related:
---
parseModule("export default (class A {})")
---
Expected: No SyntaxError
Actual: SyntaxError: local binding for export 'A' not found
Reporter | ||
Updated•8 years ago
|
Blocks: harmony:modules
Assignee | ||
Comment 1•8 years ago
|
||
The problem is that we get confused between |export default class ...| and |export default EXPRESSION| where the latter expression is a class expression.
The patch refactors ModuleBuilder::processExport to check for the presence of the second child of the parse node to determine whether it's an export default expression. This is always present in this case (see the parser code here http://searchfox.org/mozilla-central/source/js/src/frontend/Parser.cpp#5093).
I also fixed the indentation in this method.
Assignee: nobody → jcoppeard
Attachment #8826676 -
Flags: review?(shu)
Comment 2•8 years ago
|
||
Comment on attachment 8826676 [details] [diff] [review]
bug1320993-export-default-class-expr
Review of attachment 8826676 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/src/builtin/ModuleObject.cpp
@@ +1196,5 @@
> break;
> + }
> +
> + default:
> + MOZ_CRASH("Unexpected parse node");
2 spaces here. Our whacky switch style.
Attachment #8826676 -
Flags: review?(shu) → review+
Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/473e99dde77d
Fix exporting default class expression r=shu
Comment 4•8 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
You need to log in
before you can comment on or make changes to this bug.
Description
•