Bug #6332
closedLocal variable depending on current-output-uri may be evaluated with the wrong context
0%
Description
If a local variable is bound to the value of current-output-uri()
or current-output-uri#0
, and there is only a single reference to the variable, the variable reference might be inlined even though it appears within an xsl:result-document instruction where the current output URI has changed.
Revealed by XSLT 4.0 test case current-output-uri-402.
In LetExpression.optimize(), line 333 (if (ExpressionTool.changesXsltContext(getSequence())) {...}
is designed to prevent this, and it does so for dependencies on other parts of the XSLT dynamic context such as regex groups; but it doesn't take current output URI into account.
Updated by Michael Kay 3 months ago
Test current-output-uri-011
shows that this is working OK for an actual function call on current-output-uri()
. The very similar test current-output-uri-402
demonstrates that it is failing for a named function reference current-output-uri#0
.
The reason that the first test succeeds is that the call on current-output-uri()
is (rather spuriously) given the special property HAS_SIDE_EFFECTS
.
The reason that the similar test analyse-string-403 works (using regex-group rather than current-output-uri) is that the variable in question is not inlined because the instruction that changes the dynamic context (xsl:analyze-string
) is classified as a looping instruction, which prevents the variable being inlined.
Updated by Michael Kay 3 months ago
Fixed by changing ExpressionTool.changesXsltContext() to return true for a DynamicFunctionCall - for the same reasons as we do so for things like xsl:apply-templates
; we don't know what it will do, so we are conservative.
Updated by Michael Kay 3 months ago
- Status changed from New to Resolved
- Applies to branch 12, trunk added
- Fix Committed on Branch 12, trunk added
Please register to edit this issue