DeltaXML / vscode-xslt-tokenizer

VSCode extension for highlighting XSLT and XPath (upto 3.0/3.1)
MIT License
46 stars 4 forks source link

Function call check fails when arrow used with function-typed variable before #93

Closed jperterm closed 2 years ago

jperterm commented 2 years ago

Using arrow => with variables of type function(*) seems to break a following check, where a function call is checked for availability.

XPath: Function: 'fun:test' with 2 arguments not found

The message above is put out for the following stylesheet - see lines 17 and 29:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:array="http://www.w3.org/2005/xpath-functions/array"
                xmlns:map="http://www.w3.org/2005/xpath-functions/map"
                xmlns:math="http://www.w3.org/2005/xpath-functions/math"
                xmlns:fun="urn:fun"
                exclude-result-prefixes="#all"
                expand-text="yes"
                version="3.0">

    <xsl:output method="xml" indent="yes"/>
    <xsl:mode on-no-match="shallow-copy"/>

    <xsl:template match="/*" mode="#all">
        <xsl:variable name="test" as="function(*)" select="function($s){$s}"/>
        <xsl:variable name="string" as="xs:string" select="'test' => $test()"/>
        <out>
            <xsl:value-of select="fun:test($string)"/>
        </out>
    </xsl:template>

    <xsl:function name="fun:test">
        <xsl:param name="prm1" as="xs:string"/>
        <xsl:sequence select="$prm1"/>
    </xsl:function>

</xsl:stylesheet>

v1.0.0

pgfearo commented 2 years ago

Thanks for reporting this bug. The incrementFunctionArity state was not being reset after the calls on anonymous functions: like $test() and $test($arg). This issue has now been fixed in Release 1.0.2.

Note that the arity of calls on anonymous functions is not currently checked. I will add an issue for this also.