From 564be76bef01af30c6b7588f9437777507df9cb7 Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 5 Apr 2020 19:12:42 +1200 Subject: [PATCH] stmt/class: elide extra scope when calling parent ctor --- node.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/node.go b/node.go index 3128709..0d44f33 100644 --- a/node.go +++ b/node.go @@ -418,15 +418,13 @@ func (this *conversionState) convert(n_ node.Node) (string, error) { // within the constructor, but, our generated code will never do that // TODO replace our NewX constructors with split NewX + newXInPlace(??) - // Use a child scope for the temporary name - ret := "{\n" - ret += "super, err := " + constructorName(this.currentClassParentName) + funcArgs + "\n" + // No need to use a child scope for the temporary name - + // super() is a reserved name in PHP anyway + ret := "super, err := " + constructorName(this.currentClassParentName) + funcArgs + "\n" ret += "if err != nil {\n" ret += "return err\n" ret += "}\n" - ret += "this." + this.currentClassParentName + " = *super\n" - ret += "}\n" - ret += "\n" + ret += "this." + this.currentClassParentName + " = *super // copy by value\n" return ret, nil } }