Optional chaining assertions and unreachable code
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox74 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
Details
Attachments
(16 files)
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review |
var a, b;
(a + b)?.()
asserts with:
Assertion failure: (kind == ParseNodeKind::ArrayExpr || kind == ParseNodeKind::ObjectExpr || kind == ParseNodeKind::TrueExpr || kind == ParseNodeKind::FalseExpr || kind == ParseNodeKind::StringExpr || kind == ParseNodeKind::NumberExpr || kind == ParseNodeKind::RawUndefinedExpr || kind == ParseNodeKind::NullExpr || kind == ParseNodeKind::Name || kind == ParseNodeKind::Function || kind == ParseNodeKind::ThisExpr || kind == ParseNodeKind::TaggedTemplateExpr || kind == ParseNodeKind::TemplateStringExpr || kind == ParseNodeKind::AwaitExpr || kind == ParseNodeKind::RegExpExpr || kind == ParseNodeKind::ClassDecl || kind == ParseNodeKind::CommaExpr || kind == ParseNodeKind::NewExpr || kind == ParseNodeKind::SetThis || kind == ParseNodeKind::NewTargetExpr) (Unknown ParseNodeKind for OptionalChain), at /home/andre/hg/mozilla-central/js/src/frontend/BytecodeEmitter.cpp:7833
({m() { super[0]?.() }}).m()
asserts wth:
Assertion failure: initialDepth_ + 2 == depth, at /home/andre/hg/mozilla-central/js/src/frontend/OptionalEmitter.cpp:58
Comment 1•6 years ago
|
||
anba -- let me know if i can help with this.
| Assignee | ||
Comment 2•6 years ago
|
||
We already assert that this case isn't allowed in the bytecode emitter. Also
report a syntax error to match normal property access.
| Assignee | ||
Comment 3•6 years ago
|
||
Depends on D61146
| Assignee | ||
Comment 4•6 years ago
|
||
That way we don't need the explicit cast.
Depends on D61147
| Assignee | ||
Comment 5•6 years ago
|
||
Moves the isSuper() method from the base class to the (non-optional) derived
classes, because super?.x isn't valid syntax, so it's confusing to be able to
ask if an optional property access is applied on super.
The next part will further simplify BytecodeEmitter::emitDelete{Element,Property}InOptChain().
Depends on D61148
| Assignee | ||
Comment 6•6 years ago
|
||
The child node of a DeleteOptionalChainExpr node can't be a super-property
accessor, so we can remove this code.
Drive-by: Reindent some stack comments.
Depends on D61151
| Assignee | ||
Comment 7•6 years ago
|
||
super?.() isn't valid code, so we don't need to handle this case.
Depends on D61152
| Assignee | ||
Comment 8•6 years ago
|
||
The previous list contained some invalid entries (await and comma-expression)
and was missing some possible parse node kinds.
Depends on D61153
| Assignee | ||
Comment 9•6 years ago
|
||
Aligns emitOptionalElemExpression() with emitOptionalDotExpression(), so it's
easier to compare both methods against each other.
Depends on D61154
| Assignee | ||
Comment 10•6 years ago
|
||
nextMember is never nullptr, so we don't need to test for it.
Depends on D61155
| Assignee | ||
Comment 11•6 years ago
|
||
All callers pass allowCallSyntax=true, so we can omit this parameter.
Depends on D61156
| Assignee | ||
Comment 12•6 years ago
|
||
Depends on D61157
| Assignee | ||
Comment 13•6 years ago
|
||
Using optionalExpr matches the spec grammar more closely. This change also
modifies the reported error message. ++a?.b reported before this change
"unexpected token: '?.'", but now reports "invalid increment/decrement operand".
Depends on D61158
| Assignee | ||
Comment 14•6 years ago
|
||
Depends on D61159
| Assignee | ||
Comment 15•6 years ago
|
||
- We don't need to test for
tt == TokenKind::Eofwhen we return for
tt != TokenKind::OptionalChainanyway. - Omit local variable for the result value and instead use a tail-call. This
matches the local style in the parser more closely.
Depends on D61160
| Assignee | ||
Comment 16•6 years ago
|
||
This change allows the bytecode emitter to use JSOp::FunCall resp. JSOp::FunApply
for calls in optional chain expressions.
Depends on D61161
| Assignee | ||
Comment 17•6 years ago
|
||
This allows us to emit JSOp::CallIgnoresRv in optional chains.
Depends on D61162
Comment 18•6 years ago
|
||
Comment 19•6 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/bdb8620ff7f5
https://hg.mozilla.org/mozilla-central/rev/45f7fa06cc3c
https://hg.mozilla.org/mozilla-central/rev/9615eaa325ed
https://hg.mozilla.org/mozilla-central/rev/95890e60c691
https://hg.mozilla.org/mozilla-central/rev/9dba40e8b408
https://hg.mozilla.org/mozilla-central/rev/4a8a350bba27
https://hg.mozilla.org/mozilla-central/rev/5c9241e7ce20
https://hg.mozilla.org/mozilla-central/rev/958adec63532
https://hg.mozilla.org/mozilla-central/rev/fa5be03a588c
https://hg.mozilla.org/mozilla-central/rev/e82fbc9dee63
https://hg.mozilla.org/mozilla-central/rev/468ff3d2cf8e
https://hg.mozilla.org/mozilla-central/rev/849b4d84f743
https://hg.mozilla.org/mozilla-central/rev/9c5786b1bccb
https://hg.mozilla.org/mozilla-central/rev/46d27864b908
https://hg.mozilla.org/mozilla-central/rev/075c4404c2c8
https://hg.mozilla.org/mozilla-central/rev/65c1c7d322ed
Description
•