From 0d7024dbee7985dfcaf971c94d09497ec4e52fd2 Mon Sep 17 00:00:00 2001 From: mappu Date: Tue, 7 Apr 2020 22:52:12 +1200 Subject: [PATCH] node: remove `throw ""` -> `errors.New("")` transform, as PHP cannot throw scalars --- node.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/node.go b/node.go index b2dfac9..85c764e 100644 --- a/node.go +++ b/node.go @@ -355,12 +355,12 @@ func (this *conversionState) convertNoFreeFloating(n_ node.Node) (string, error) // Treat as an err return // FIXME we don't know the default return type for the function we're in - // If the expr is a string literal, we can convert it to errors.New() - // Although we probably can't do this in general for stringly-typed expressions + // PHP can only throw objects, not literals/scalars + // If the expr is just new Exception, we can convert it to errors.New() - if str, ok := n.Expr.(*scalar.String); ok { - return "return nil, errors.New(" + str.Value + ")\n", nil - } + //if str, ok := n.Expr.(*scalar.String); ok { + // return "return nil, errors.New(" + str.Value + ")\n", nil + //} child, err := this.convert(n.Expr) if err != nil {