Closed
Bug 1202665
Opened 10 years ago
Closed 9 years ago
In an ES6 class, `"constructor"(){}` with double quotes is not recognized as a constructor
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla50
People
(Reporter: anba, Assigned: efaust)
References
Details
Attachments
(1 file)
1.44 KB,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
Test case:
---
(class {"\u0063onstructor"(){}})
---
Assertion failure: constructor (For now, no default constructors), at /home/andre/git/mozilla-central/js/src/frontend/BytecodeEmitter.cpp:7437
Stack:
---
#0 0x00000000006a6a7e in js::frontend::BytecodeEmitter::emitClass (this=0x7fffffffce88, pn=0x7ffff698a178)
at /home/andre/git/mozilla-central/js/src/frontend/BytecodeEmitter.cpp:7437
#1 0x00000000006a8652 in js::frontend::BytecodeEmitter::emitTree (this=0x7fffffffce88, pn=0x7ffff698a178)
at /home/andre/git/mozilla-central/js/src/frontend/BytecodeEmitter.cpp:8015
#2 0x00000000006a329e in js::frontend::BytecodeEmitter::emitStatement (this=0x7fffffffce88, pn=0x7ffff698a1b0)
at /home/andre/git/mozilla-central/js/src/frontend/BytecodeEmitter.cpp:6417
#3 0x00000000006a7914 in js::frontend::BytecodeEmitter::emitTree (this=0x7fffffffce88, pn=0x7ffff698a1b0)
at /home/andre/git/mozilla-central/js/src/frontend/BytecodeEmitter.cpp:7698
#4 0x000000000068a66a in BytecodeCompiler::prepareAndEmitTree (this=0x7fffffffc1d0, ppn=0x7fffffffbdb0, pc=...)
at /home/andre/git/mozilla-central/js/src/frontend/BytecodeCompiler.cpp:386
#5 0x000000000068b614 in BytecodeCompiler::compileScript (this=0x7fffffffc1d0, scopeChain=..., evalCaller=...)
at /home/andre/git/mozilla-central/js/src/frontend/BytecodeCompiler.cpp:605
#6 0x000000000068c78e in js::frontend::CompileScript (cx=0x7ffff6908c00, alloc=0x7ffff6937310, scopeChain=..., enclosingStaticScope=...,
evalCaller=..., options=..., srcBuf=..., source_=0x0, extraSct=0x0, sourceObjectOut=0x0)
at /home/andre/git/mozilla-central/js/src/frontend/BytecodeCompiler.cpp:807
#7 0x0000000000d48f0b in Compile (cx=0x7ffff6908c00, options=..., scopeOption=HasSyntacticScope, srcBuf=..., script=...)
at /home/andre/git/mozilla-central/js/src/jsapi.cpp:3954
#8 0x0000000000d48fe5 in Compile (cx=0x7ffff6908c00, options=..., scopeOption=HasSyntacticScope,
chars=0x7ffff3c10920 u"(class {\"\\u0063onstructor\"(){}})\n", length=33, script=...) at /home/andre/git/mozilla-central/js/src/jsapi.cpp:3963
#9 0x0000000000d4916d in Compile (cx=0x7ffff6908c00, options=..., scopeOption=HasSyntacticScope,
bytes=0x7ffff3dfdc80 "(class {\"\\u0063onstructor\"(){}})\n", '\344' <repeats 31 times>, '\345' <repeats 135 times>, <incomplete sequence \345>..., length=33, script=...) at /home/andre/git/mozilla-central/js/src/jsapi.cpp:3978
#10 0x0000000000d4943b in JS::Compile (cx=0x7ffff6908c00, options=...,
bytes=0x7ffff3dfdc80 "(class {\"\\u0063onstructor\"(){}})\n", '\344' <repeats 31 times>, '\345' <repeats 135 times>, <incomplete sequence \345>..., length=33, script=...) at /home/andre/git/mozilla-central/js/src/jsapi.cpp:4015
#11 0x00000000004310d5 in EvalAndPrint (cx=0x7ffff6908c00,
bytes=0x7ffff3dfdc80 "(class {\"\\u0063onstructor\"(){}})\n", '\344' <repeats 31 times>, '\345' <repeats 135 times>, <incomplete sequence \345>..., length=33, lineno=1, compileOnly=false, out=0x7ffff6f6a740 <_IO_2_1_stdout_>) at /home/andre/git/mozilla-central/js/src/shell/js.cpp:482
#12 0x0000000000431654 in ReadEvalPrintLoop (cx=0x7ffff6908c00, in=0x7ffff6f69980 <_IO_2_1_stdin_>, out=0x7ffff6f6a740 <_IO_2_1_stdout_>,
compileOnly=false) at /home/andre/git/mozilla-central/js/src/shell/js.cpp:551
#13 0x0000000000431817 in Process (cx=0x7ffff6908c00, filename=0x0, forceTTY=true) at /home/andre/git/mozilla-central/js/src/shell/js.cpp:582
#14 0x00000000004463ea in ProcessArgs (cx=0x7ffff6908c00, op=0x7fffffffd9b0) at /home/andre/git/mozilla-central/js/src/shell/js.cpp:5801
#15 0x000000000044770c in Shell (cx=0x7ffff6908c00, op=0x7fffffffd9b0, envp=0x7fffffffdbb8)
at /home/andre/git/mozilla-central/js/src/shell/js.cpp:6121
#16 0x0000000000448a87 in main (argc=1, argv=0x7fffffffdba8, envp=0x7fffffffdbb8) at /home/andre/git/mozilla-central/js/src/shell/js.cpp:6470
---
Reporter | ||
Comment 1•10 years ago
|
||
The original test case no longer asserts now that bug 1105463 has landed, but the underlying issue is still present.
New test case:
---
new (class {"\u0063onstructor"(){ print("ok") }})
---
Expected: Prints "ok"
Actual: "ok" is not printed
Reporter | ||
Updated•10 years ago
|
Blocks: harmony-classes
Updated•9 years ago
|
Summary: Assertion failure: constructor (For now, no default constructors) → In an ES6 class, `"constructor"(){}` with double quotes is not recognized as a constructor
Assignee | ||
Comment 2•9 years ago
|
||
Silly. Thanks for the report.
Assignee: nobody → efaustbmo
Status: NEW → ASSIGNED
Attachment #8762965 -
Flags: review?(jwalden+bmo)
Comment 3•9 years ago
|
||
Comment on attachment 8762965 [details] [diff] [review]
Fix
Review of attachment 8762965 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/src/frontend/BytecodeEmitter.cpp
@@ +8593,5 @@
> ClassMethod& method = mn->as<ClassMethod>();
> ParseNode& methodName = method.name();
> if (!method.isStatic() &&
> + (methodName.isKind(PNK_OBJECT_PROPERTY_NAME) ||
> + methodName.isKind(PNK_STRING)) &&
Mild preference for these two on the same line if they fit, since it's three conditions, one of which is an or.
Attachment #8762965 -
Flags: review?(jwalden+bmo) → review+
Pushed by efaustbmo@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/44c0fa7ded60
Recognize "contructor"() methods as class constructors. (r=Waldo)
Comment 6•9 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox50:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in
before you can comment on or make changes to this bug.
Description
•