From a22da9398a3fea39fd9d279ddb36d975043d407e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Fri, 7 Sep 2018 14:24:59 +0200
Subject: [PATCH] Parser.XML.Tree: Declare low_clone() as optional.

Fixes issues assigning eg a SimpleElementNode object to
a variable declared as a SimpleNode in strict_types mode.

Fixes [PIKE-122].
---
 .gitattributes                             |  1 -
 lib/modules/Parser.pmod/XML.pmod/Tree.pmod | 10 +++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/.gitattributes b/.gitattributes
index 2246fcac5c..258bd6739a 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -159,7 +159,6 @@ testfont binary
 /lib/modules/Parser.pmod/Python.pmod foreign_ident
 /lib/modules/Parser.pmod/RCS.pike foreign_ident
 /lib/modules/Parser.pmod/SGML.pike foreign_ident
-/lib/modules/Parser.pmod/XML.pmod/Tree.pmod foreign_ident
 /lib/modules/Parser.pmod/XML.pmod/Validating.pike foreign_ident
 /lib/modules/Parser.pmod/XML.pmod/testsuite.in foreign_ident
 /lib/modules/Parser.pmod/module.pmod foreign_ident
diff --git a/lib/modules/Parser.pmod/XML.pmod/Tree.pmod b/lib/modules/Parser.pmod/XML.pmod/Tree.pmod
index bd65f2ad8c..05cf8b3354 100644
--- a/lib/modules/Parser.pmod/XML.pmod/Tree.pmod
+++ b/lib/modules/Parser.pmod/XML.pmod/Tree.pmod
@@ -1,7 +1,7 @@
 #pike __REAL_VERSION__
 
 /*
- * $Id: Tree.pmod,v 1.72 2008/06/28 16:36:55 nilsson Exp $
+ * $Id$
  *
  */
 
@@ -283,7 +283,7 @@ class AbstractSimpleNode {
   //! Returns an initialized copy of the node.
   //! @note
   //!   The returned node has no children.
-  AbstractSimpleNode low_clone() {
+  optional AbstractSimpleNode low_clone() {
     return AbstractSimpleNode();
   }
 
@@ -537,7 +537,7 @@ class AbstractNode {
   //! Returns an initialized copy of the node.
   //! @note
   //!   The returned node has no children, and no parent.
-  AbstractNode low_clone()
+  optional AbstractNode low_clone()
   {
     return AbstractNode();
   }
@@ -1309,7 +1309,7 @@ class SimpleNode
   inherit VirtualNode;
 
   // Needed for cross-overloading
-  SimpleNode low_clone()
+  optional SimpleNode low_clone()
   {
     return VirtualNode::low_clone();
   }
@@ -1323,7 +1323,7 @@ class Node
   inherit VirtualNode;
 
   // Needed for cross-overloading
-  Node low_clone()
+  optional Node low_clone()
   {
     return VirtualNode::low_clone();
   }
-- 
GitLab