Fix pipe expression start (#746)

This commit is contained in:
Adam Chalmers
2023-09-29 22:19:20 -04:00
committed by GitHub
parent 83907fa9db
commit 9797d0cb81
2 changed files with 7 additions and 3 deletions

View File

@ -403,7 +403,7 @@ describe('testing pipe operator special', () => {
id: { type: 'Identifier', start: 6, end: 14, name: 'mySketch' }, id: { type: 'Identifier', start: 6, end: 14, name: 'mySketch' },
init: { init: {
type: 'PipeExpression', type: 'PipeExpression',
start: 15, start: 17,
end: 145, end: 145,
body: [ body: [
{ {
@ -644,7 +644,7 @@ describe('testing pipe operator special', () => {
}, },
init: { init: {
type: 'PipeExpression', type: 'PipeExpression',
start: 12, start: 14,
end: 36, end: 36,
body: [ body: [
{ {

View File

@ -1283,7 +1283,11 @@ impl Parser {
let end_token = self.get_token(pipe_body_result.last_index)?; let end_token = self.get_token(pipe_body_result.last_index)?;
Ok(PipeExpressionResult { Ok(PipeExpressionResult {
expression: PipeExpression { expression: PipeExpression {
start: current_token.start, start: pipe_body_result
.body
.first()
.map(|v| v.start())
.unwrap_or(current_token.start),
end: end_token.end, end: end_token.end,
body: pipe_body_result.body, body: pipe_body_result.body,
non_code_meta: pipe_body_result.non_code_meta, non_code_meta: pipe_body_result.non_code_meta,