Project

Profile

Help

Support #3233

closed

Unused local variable gets evaluated, causing an error

Added by Radu Coravu over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Performance
Sprint/Milestone:
-
Start date:
2017-05-23
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.7, 9.8
Fix Committed on Branch:
9.7, 9.8
Fixed in Maintenance Release:
Platforms:

Description

This is not really a bug, maybe it's a request for comment.

For this XSLT stylesheet:

<xsl:stylesheet xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    version="2.0">
    <xsl:output indent="yes"/>
    <xsl:template match="/">
        <xsl:variable name="totalCost">
            <xsl:call-template name="sum">
            </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="totalVAT" select="($totalCost*0.24)">
        </xsl:variable>
        <root></root>
    </xsl:template>
    <xsl:template name="sum"/>
</xsl:stylesheet>

Saxon 9.7 reports this problem on the variable called totalVAT

FORG0001: String to double conversion: no digits found

which is OK because the "totalCost" is an empty string and cannot be multiplied as an integer.

Somehow Saxon 9.6 never reported this problem, probably because it never evaluated the $totalCost as it is not used anywhere.

So Saxon 9.7 seems more eager to evaluate variables, even if they are not used.


Files

invoiceVendor.xml (781 Bytes) invoiceVendor.xml Radu Coravu, 2017-07-20 12:38
invoiceVendor.xsl (12.1 KB) invoiceVendor.xsl Radu Coravu, 2017-07-20 12:38

Please register to edit this issue

Also available in: Atom PDF