@@ -804,7 +804,7 @@ BoundExpression BindIsMemberOfChain(AST.Expression expr, BoundAccess access)
804804
805805 protected BoundExpression BindFunctionCall ( AST . FunctionCall x , BoundExpression boundTarget = null )
806806 {
807- if ( Routine != null )
807+ if ( Routine != null && x . CallSignature . IsCallableConvert == false )
808808 {
809809 // TODO: ignore well-known library functions
810810 Routine . Flags |= RoutineFlags . HasUserFunctionCall ;
@@ -827,6 +827,11 @@ protected BoundExpression BindFunctionCall(AST.FunctionCall x, BoundExpression b
827827
828828 if ( x . CallSignature . IsCallableConvert ) // callable convert syntax (...)
829829 {
830+ if ( boundTarget == null )
831+ {
832+ // TODO: consider global function fallback name // return new BoundConvertToCallable(new BoundLiteral(fname.Name), DeclaringCompilation);
833+ }
834+
830835 return new BoundCallableConvert ( boundTarget , new BoundRoutineName ( fname . Name ) , DeclaringCompilation ) ;
831836 }
832837
@@ -1340,12 +1345,15 @@ protected virtual BoundExpression BindBinaryEx(AST.BinaryEx expr)
13401345 goto default ;
13411346
13421347 case AST . Operations . Pipe :
1348+
1349+ var target = BindExpression ( expr . RightExpr , BoundAccess . Read ) ;
1350+
13431351 // Template: A |> B;
13441352 // A: PhpValue
1345- // B: IPhpoCallable
1353+ // B: IPhpCallable
13461354 return new BoundBinaryEx (
13471355 BindExpression ( expr . LeftExpr , laccess ) ,
1348- new BoundConvertToCallable ( BindExpression ( expr . RightExpr , BoundAccess . Read ) , this . DeclaringCompilation ) ,
1356+ target as BoundConvertToCallable ?? new BoundConvertToCallable ( target , this . DeclaringCompilation ) ,
13491357 expr . Operation
13501358 ) ;
13511359
0 commit comments