Implement the Optional Chaining operator (?.) proposal
Categories
(Core :: JavaScript Engine, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox74 | --- | fixed |
People
(Reporter: alex.fdm, Assigned: yulia)
References
(Blocks 1 open bug, )
Details
(Keywords: dev-doc-complete, parity-chrome, parity-safari)
Attachments
(4 files, 6 obsolete files)
The proposal is currently on Stage 2.
Reporter | ||
Updated•5 years ago
|
Changing "Blocks" to Stage 3 per https://github.com/tc39/proposals/commit/25f8d6a4db03bcdd2cfd49bf32e312ce80e1c80e
Comment 4•5 years ago
|
||
It's implemented in both V8 and JSC now
Reporter | ||
Updated•5 years ago
|
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 5•5 years ago
|
||
Assignee | ||
Comment 6•5 years ago
|
||
Assignee | ||
Comment 8•5 years ago
|
||
Assignee | ||
Comment 9•5 years ago
|
||
Depends on D58973
Assignee | ||
Comment 10•5 years ago
|
||
Depends on D58974
Assignee | ||
Comment 11•5 years ago
|
||
Depends on D58975
Assignee | ||
Comment 12•5 years ago
|
||
Depends on D58976
Assignee | ||
Comment 13•5 years ago
|
||
Depends on D58977
Assignee | ||
Comment 14•5 years ago
|
||
Depends on D58974
Assignee | ||
Comment 15•5 years ago
|
||
Depends on D59869
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Comment 16•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/37071f53b00b
https://hg.mozilla.org/mozilla-central/rev/35b55a5b0e4d
https://hg.mozilla.org/mozilla-central/rev/254be9b0aaee
https://hg.mozilla.org/mozilla-central/rev/5d3392ccb733
Comment 17•5 years ago
|
||
Yulia, as I started working on Bug 1594009 for console support, I wanted to check with you if it's normal for
document?.location?["origin"];
to throw a SyntaxError ? Chrome does the same, but in https://tc39.es/proposal-optional-chaining/ there are a few places where it looks like it should be possible? (I'm really not used to read specs, so I definitely can be wrong).
Assignee | ||
Comment 18•5 years ago
|
||
Hi Nicolas,
Unfortunately, we can't use location?["origin"]
because we cannot distinguish it from a ternary without a look ahead larger than one or two characters. the engine, when it sees a bare ?
, it expects a ternary operator -> location ? ["origin"] : ...
, which is what the syntax error refers to.
As a result, the committee settled on this syntax -> location?.["origin"]
-- it isn't ideal, but it resolves the lookahead problem. if we didn't do it right away, we would have potential errors with automatic semicolon insertion, thus making it impossible for us to include it later due to web compat.
The same is true for function calls.
So, tl;dr-> yes, it should be a syntax error specifically for an incomplete ternary expression.
Comment 19•5 years ago
|
||
(In reply to Yulia Startsev [:yulia] from comment #18)
So, tl;dr-> yes, it should be a syntax error specifically for an incomplete ternary expression.
Thanks a lot for the explanation :)
Comment 20•5 years ago
|
||
Release notes: https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/74#JavaScript
Reference docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
Description
•