Bug #1792
Updated by O'Neil Delpratt almost 11 years ago
Given the following stylesheet code snippet: <pre><code class="xml"> <xsl:variable name="current_version" as="xs:string" select="'1.0'"/> <xsl:template name="t_element"> <xsl:param name="ver" as="xs:string?" select="$current_version"/> <xsl:element name="test"><xsl:value-of select="xs:double($ver) >= xs:double('1.1')" /></xsl:element> </xsl:template> </code></pre> The following exception is thrown when bytecode generation option is 'on'. The problem here is that the variable declared as xs:string is used in as the default value of a param instruction xs:string, which has @as@ attribute @xs:string?. This is a zero or one occurance , which when used in the xs:double construct is not being correctly converted to xs:double in the byte code. I confirm that the correct type conversion happens in the interpreted code: <pre> java.lang.ArrayIndexOutOfBoundsException: 1 at org.objectweb.asm.Frame.a(Unknown Source) at org.objectweb.asm.Frame.a(Unknown Source) at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source) at org.objectweb.asm.commons.GeneratorAdapter.endMethod(Unknown Source) at com.saxonica.bytecode.util.CompilerService.compileToByteCode(CompilerService.java:636) at com.saxonica.expr.ee.OptimizerEE.compileToByteCode(OptimizerEE.java:1338) at net.sf.saxon.style.XSLTemplate.optimize(XSLTemplate.java:464) at net.sf.saxon.style.PrincipalStylesheetModule.compileStylesheet(PrincipalStylesheetModule.java:818) at net.sf.saxon.PreparedStylesheet.setStylesheetDocument(PreparedStylesheet.java:391) at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:236) at net.sf.saxon.PreparedStylesheet.compile(PreparedStylesheet.java:114) at net.sf.saxon.Transform.doTransform(Transform.java:565) at net.sf.saxon.Transform.main(Transform.java:82) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) Error </pre>