Closed Bug 1566143 Opened 5 years ago Closed 5 years ago

Implement the Optional Chaining operator (?.) proposal

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla74
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.

Summary: Implement the Optional Chaining operator () proposal → Implement the Optional Chaining operator (?.) proposal

This is being set as a P3 like other Stage 2 proposals

Priority: -- → P3

This proposal has been promoted to Stage 3

It's implemented in both V8 and JSC now

Assignee: nobody → ystartsev
Status: NEW → ASSIGNED

The proposal is now on Stage 4.

Depends on D58973

Depends on D58976

Depends on D58977

Depends on D58974

Depends on D59869

Attachment #9119160 - Attachment is obsolete: true
Attachment #9119161 - Attachment is obsolete: true
Attachment #9119162 - Attachment is obsolete: true
Attachment #9119163 - Attachment is obsolete: true
Attachment #9110892 - Attachment is obsolete: true
Attachment #9108760 - Attachment is obsolete: true

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).

Flags: needinfo?(ystartsev)

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.

Flags: needinfo?(ystartsev)

(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 :)

Depends on: 1611777
Regressions: 1617168
Regressions: 1633683
Regressions: 1644839
Regressions: 1650340
Regressions: 1685260
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: