You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
The current grammar does not correctly raise early errors for x |> ((%) => {}) and x |> (async (%) => {}). This is because, inside of a PipeBody, % is hidden from the Contains operation—including in any CoverParenthesizedExpressionAndArrowParameterList that is within the PipeBody.
So, just like how the current grammar (correctly) allows x |> ((%)), so too does it (incorrectly) allow x |> ((%) => {}). In both cases, PipeBody contains a topic inside of two nested CoverParenthesizedExpressionAndArrowParameterLists.
@lightmare pointed to AssignmentTargetType as a good place to prohibit the topic for these cases. This should also let expressions like x |> %[y] = z, x |> y[%] = z, and x |> ((y = %) => {}) remain correctly valid.
(@JLHwung also said that the current grammar also does not correctly raise early errors for x |> (% = 0) and x |> (% += 0). However, I’m not sure if this is true.LeftHandSideExpression allows only NewExpression, CallExpression, and OptionalExpression, and none of these expressions can result in an assignment to a topic reference.)
The text was updated successfully, but these errors were encountered:
@lightmare: Thanks for the correction; I was mistaken. The grammar currently correctly prohibits x |> ((%) => {}) ((%) matches neither BindingIdentifier nor ( UniqueFormalParameters )) but incorrectly allows x |> (% = 0). Either way, we should add a restriction to AssignmentTargetType as you suggested.
js-choi
changed the title
Grammar allows topic in some arrow parameters
Grammar allows topic in some assignment targets
Jul 16, 2021
@JLHwung raised a concern in babel/babel#13536 (comment). To prevent cluttering up babel/babel#13536, I’m opening an issue here. The topic token is assumed to be
%
in this issue.The current grammar does not correctly raise early errors forx |> ((%) => {})
andx |> (async (%) => {})
. This is because, inside of a PipeBody,%
is hidden from the Contains operation—including in any CoverParenthesizedExpressionAndArrowParameterList that is within the PipeBody.So, just like how the current grammar (correctly) allows
x |> ((%))
, so too does it (incorrectly) allowx |> ((%) => {})
. In both cases, PipeBody contains a topic inside of two nested CoverParenthesizedExpressionAndArrowParameterLists.@lightmare pointed to AssignmentTargetType as a good place to prohibit the topic for these cases. This should also let expressions like
x |> %[y] = z
,x |> y[%] = z
, andx |> ((y = %) => {})
remain correctly valid.(@JLHwung also said that the current grammar also does not correctly raise early errors for
x |> (% = 0)
andx |> (% += 0)
.However, I’m not sure if this is true.LeftHandSideExpression allows only NewExpression, CallExpression, and OptionalExpression, andnone of these expressions can result in an assignment to a topic reference.)The text was updated successfully, but these errors were encountered: