"Bad parent pointer" after simplifying nested blocks.
Given the following template rule:
<xsl:template name="t" as="node()*"> <xsl:param name="e" as="element()?"/> <xsl:sequence select="$e, $e"/> </xsl:template>
we get several "Bad parent pointer found" warning messages during compilation.
Originally raised here: https://saxonica.plan.io/boards/3/topics/6838?r=6841
#1 Updated by Michael Kay almost 4 years ago
Internally, Saxon represents both a sequence constructor and a comma-expression as a "Block" expression, so the initial structure of the expression tree here is
Block(Param, Block($e, $e))
The simplify() operation on a Block flattens any nested blocks, so this is reduced to:
Block(Param $e, $e)
It seems that this flattening operation is not resetting parent pointers on the 3 child expressions to the new flattened Block.
#3 Updated by Michael Kay almost 4 years ago
XSLTemplate.refineTemplateBody() is doing
Expression result = body.simplify();
which modifies the subexpressions of body to point to "result" as the new parent; this means that the tree underneath "body" is no longer valid.
But then (on this particular path) it is subsequently doing
result = typeCheck(body);
which uses the original tree rather than the simplified tree as input.
Please register to edit this issue