<commit_before>(: 
  Test for improved error messages logic:
  the error message should not contain the "missing comma?" hint
:)

import module namespace refl = "http://www.zorba-xquery.com/modules/reflection";
declare namespace err="http://www.w3.org/2005/xqt-errors";

try 
{

refl:eval(
'declare namespace an = "http://www.zorba-xquery.com/annotations";

 declare %an:sequential function local:image(
   $id as xs:string, $width as xs:int*,
   $height as xs:int*, $ratio as xs:decimal*, $format as xs:string) as xs:base64Binary
 {
   variable $obj := null;

   if (fn:empty($obj)) then
     ()
   else
   {
     variable $svg := $obj("svg");
     if (fn:not(jn:is-null($obj("size")("width")))) then
     {
       variable $svg-width := $obj("size")("width");
       variable $svg-height := $obj("size")("height");

       if ($width) then
       {
         $svg-height := xs:int(($svg-height div $svg-width) * $width);
         $svg-width := $width;
       }
       else if ($height) then
       {
         $svg-width := xs:int(($svg-width div $svg-height) * $height);
         $svg-height := $height;
       }
       else if ($ratio) then
       {
         $svg-width := xs:int($svg-width * $ratio);
         $svg-height := xs:int($svg-height * $ratio);
       }
       else
         {} 

       $svg := <a>{$svg}</a>/*;

       replace value of node $svg/@height width xs:string($svg-height) || "px";
     }
     else
     {
     }
   }   

 };        

()'
)

}
catch err:XPST0003
{
  $err:description eq 'invalid expression: syntax error, unexpected "QName", expecting "with"'
}<commit_msg>Updated test result to take into account the qname parser error message fix<commit_after>(: 
  Test for improved error messages logic:
  the error message should not contain the "missing comma?" hint
:)

import module namespace refl = "http://www.zorba-xquery.com/modules/reflection";
declare namespace err="http://www.w3.org/2005/xqt-errors";

try 
{

refl:eval(
'declare namespace an = "http://www.zorba-xquery.com/annotations";

 declare %an:sequential function local:image(
   $id as xs:string, $width as xs:int*,
   $height as xs:int*, $ratio as xs:decimal*, $format as xs:string) as xs:base64Binary
 {
   variable $obj := null;

   if (fn:empty($obj)) then
     ()
   else
   {
     variable $svg := $obj("svg");
     if (fn:not(jn:is-null($obj("size")("width")))) then
     {
       variable $svg-width := $obj("size")("width");
       variable $svg-height := $obj("size")("height");

       if ($width) then
       {
         $svg-height := xs:int(($svg-height div $svg-width) * $width);
         $svg-width := $width;
       }
       else if ($height) then
       {
         $svg-width := xs:int(($svg-width div $svg-height) * $height);
         $svg-height := $height;
       }
       else if ($ratio) then
       {
         $svg-width := xs:int($svg-width * $ratio);
         $svg-height := xs:int($svg-height * $ratio);
       }
       else
         {} 

       $svg := <a>{$svg}</a>/*;

       replace value of node $svg/@height width xs:string($svg-height) || "px";
     }
     else
     {
     }
   }   

 };        

()'
)

}
catch err:XPST0003
{
  $err:description eq 'invalid expression: syntax error, unexpected qualified name "width", expecting "with"'
}
{'fraction_non_alphanumeric': 0.1712014674411495, 'fraction_numerical': 0.006725771935188016, 'mean_word_length': 2.4919957310565635, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6100402', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1069, 'n_words': 266}