Closed js-choi closed 3 years ago
Perhaps, because to a human a.b?.c::fn()
could mean:
(a.b?.c)::fn()
(a.b)?.(c::fn())
?
@ljharb: Maybe, although I think that a.b?.c::fn()
“obviously” reads as (a.b?.c)::fn()
, in the same way that a.b?.c.d()
“obviously” reads as (a.b?.c).d()
, but maybe I’m wrong. I guess we’re not sure if @waldemarhorwat meant human visual ambiguity or grammatical ambiguity.
Look at the meeting notes. The example I gave during the meeting is a?.b::c.d
. The OptionalChain production parses it as both «a?.b::c».d
and a?.b::«c.d»
.
@waldemarhorwat: Thanks for the catch. This indeed seems like a bug. It seems like it should be fixable by changing:
OptionalChain :
OptionalChain `::` SimpleMemberExpression
…to:
OptionalChain :
OptionalChain `::` SimpleMemberExpression [lookahead != `.`]
At the Committee plenary today, @waldemarhorwat expressed concern that (from my memory, might be incorrect)
a.b?.c::fn
is ambiguous.I’m not sure where the ambiguity comes from yet.
a.b?.c::fn
is equivalent to(a.b?.c)::fn
. The specification has an OptionalChain :: OptionalChain::
SimpleMemberExpression production, anda.b?.c::fn
should be:a.b
?.
c
::
fn
But I may well be missing something.