Quodatum / xqlint

XQuery Quality Checker
https://www.npmjs.com/package/@quodatum/xqlint
Apache License 2.0
1 stars 0 forks source link

[bug] local function arg reported unused #18

Closed apb2006 closed 1 year ago

apb2006 commented 1 year ago

Version: 0.2.2

declare function local:template($a as xs:string)
as xs:string{   
    $a
};
local:template("b") 

Error:

 {
    pos: { sl: 3, sc: 10, el: 3, ec: 11 },
    type: 'error',
    level: 'error',
    message: '[XPST0008] "a": undeclared variable'
  }
apb2006 commented 1 year ago

AST

  <XQuery>
   <Module>
    <MainModule>
     <Prolog>
      <AnnotatedDecl>
       <TOKEN>declare</TOKEN>
       <WS> </WS>
       <FunctionDecl>
        <TOKEN>function</TOKEN>
        <WS> </WS>
        <EQName>local:template</EQName>
        <TOKEN>(</TOKEN>
        <ParamList>
         <Param>
          <TOKEN>$</TOKEN>
          <EQName>a</EQName>
          <WS> </WS>
          <TypeDeclaration>
           <TOKEN>as</TOKEN>
           <WS> </WS>
           <SequenceType>
            <ItemType>
             <AtomicOrUnionType>
              <EQName>xs:string</EQName>
             </AtomicOrUnionType>
            </ItemType>
           </SequenceType>
          </TypeDeclaration>
         </Param>
        </ParamList>
        <TOKEN>)</TOKEN>
        <WS>
</WS>
        <TOKEN>as</TOKEN>
        <WS> </WS>
        <SequenceType>
         <ItemType>
          <AtomicOrUnionType>
           <EQName>xs:string</EQName>
          </AtomicOrUnionType>
         </ItemType>
        </SequenceType>
        <FunctionBody>
         <EnclosedExpr>
          <TOKEN>{</TOKEN>
          <WS>
    </WS>
          <Expr>
           <ExprSingle>
            <VarRef>
             <TOKEN>$</TOKEN>
             <VarName>
              <EQName>a</EQName>
             </VarName>
            </VarRef>
           </ExprSingle>
          </Expr>
          <WS>
</WS>
          <TOKEN>}</TOKEN>
         </EnclosedExpr>
        </FunctionBody>
       </FunctionDecl>
      </AnnotatedDecl>
      <Separator>
       <TOKEN>;</TOKEN>
      </Separator>
     </Prolog>
     <WS>
</WS>
     <QueryBody>
      <Expr>
       <ExprSingle>
        <FunctionCall>
         <FunctionEQName>
          <EQName>local:template</EQName>
         </FunctionEQName>
         <ArgumentList>
          <TOKEN>(</TOKEN>
          <Argument>
           <ExprSingle>
            <Literal>
             <StringLiteral>"b"</StringLiteral>
            </Literal>
           </ExprSingle>
          </Argument>
          <TOKEN>)</TOKEN>
         </ArgumentList>
        </FunctionCall>
       </ExprSingle>
      </Expr>
     </QueryBody>
    </MainModule>
   </Module>
   <WS> </WS>
   <EOF>
   </EOF>
  </XQuery>