From 5435a9a4a85d8829b1e380dbcfc4fb8768151af2 Mon Sep 17 00:00:00 2001 From: Erik Demaine Date: Sun, 5 Jan 2025 12:25:30 -0500 Subject: [PATCH] Fix pipe into certain `new` expressions Fixes #1674 --- source/parser/pipe.civet | 3 +-- test/pipe.civet | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/parser/pipe.civet b/source/parser/pipe.civet index c06b15ed..8f827cf8 100644 --- a/source/parser/pipe.civet +++ b/source/parser/pipe.civet @@ -73,9 +73,8 @@ function constructInvocation(fn: ExprWithComments, arg: ASTNode!) if lhs.type is "NewExpression" { expression } .= lhs expression = { - ...expression type: "CallExpression" - children: [ ...expression.children, call ] + children: [ expression, call ] } { ...lhs diff --git a/test/pipe.civet b/test/pipe.civet index 33d86dda..530151ff 100644 --- a/test/pipe.civet +++ b/test/pipe.civet @@ -330,6 +330,14 @@ describe "pipe", -> new Foo(x)(x) """ + throws """ + pipe to invalid new + --- + x |> new . + --- + ParseErrors: unknown:1:10 Partial placeholder . outside of call expression + """ + testCase """ pipe from new ---