<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>3829</bug_id>
          
          <creation_ts>2006-10-13 14:36:12 +0000</creation_ts>
          <short_desc>Static typing of function declarations</short_desc>
          <delta_ts>2006-12-15 18:42:49 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XML Query Test Suite</product>
          <component>XML Query Test Suite</component>
          <version>1.0.1</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nick Jones">nick</reporter>
          <assigned_to name="Carmelo Montanez">carmelo</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>12433</commentid>
    <comment_count>0</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2006-10-13 14:36:12 +0000</bug_when>
    <thetext>The following function declarations contain parameters without a declared type. 5.15 of the Formal Semantics states these are given the item()* sequence type. But the functions expect them to be a different type. For example, in function-declaration-006:

declare function local:mysum($i, $j)
{
   let $j := $i + $j
   return $j
};

This does not type check as $i + $j expectes anyAtomicType?


Could these functions be modified to define types for the parameters.


function-declaration-003
function-declaration-005
function-declaration-006
function-declaration-017</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12437</commentid>
    <comment_count>1</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2006-10-13 14:57:04 +0000</bug_when>
    <thetext>Same issues in

default_namespace-003
default_namespace-005
default_namespace-006
default_namespace-016
default_namespace-017</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13153</commentid>
    <comment_count>2</comment_count>
    <who name="Carmelo Montanez">carmelo</who>
    <bug_when>2006-12-12 22:18:43 +0000</bug_when>
    <thetext>Nick:

Thanks for the comment.  I changed the tests to add types for the arguments.
However no change was made to default_namespace-016 as I do not see the static typing issue.

Thanks,
Carmelo</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13166</commentid>
    <comment_count>3</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2006-12-13 17:08:15 +0000</bug_when>
    <thetext>We are currently throwing a err:XPTY0018 &quot;a type error if the result of the last step in a path expression contains both nodes and atomic values.&quot; during static type checking.

What happens is, because it has no return type, the function title type checks with a return type item()*.

item()* can contain both nodes and anyAtomicTypes, so when we static type check the path expression we throw the XPTY0018 as the type is not a node sequence or an atomimc type sequence.

Looking through the spec again I can&apos;t at the moment find anything specifying this check should we done during static typing rather than evaluation, so maybe it is just us being too zealous in the static type checking.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13172</commentid>
    <comment_count>4</comment_count>
    <who name="Frans Englich">frans.englich</who>
    <bug_when>2006-12-13 18:07:38 +0000</bug_when>
    <thetext>I agree default_namespace-016 has a type error, but I don&apos;t think it&apos;s XPTY0018.

XPTY0018 is raised when the last step contains a mixture. The last step in default_namespace-016 has type item()*. It&apos;s hasn&apos;t been proven that it contains a mixture of items. A mixture of nodes and atomic values is one possible instance of item()*, but so is only nodes and only atomic values as well.

I believe XPTY0004 is the correct error to raise because currently the query can&apos;t be statically type checked in a sound way.

I suggest fixing the test by adding XPTY0004 as an alternative baseline.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13179</commentid>
    <comment_count>5</comment_count>
    <who name="Carmelo Montanez">carmelo</who>
    <bug_when>2006-12-14 15:40:38 +0000</bug_when>
    <thetext>Frans/Nick:

Al lgood points, but by looking at the test, the purpose of it is not to
throw an error at all.  What if we change the fucntion to return element(),
This should take care of those static typing issues.

Carmelo</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13180</commentid>
    <comment_count>6</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2006-12-14 16:03:45 +0000</bug_when>
    <thetext>Yep. Adding a return type to the function would be a good solution. But I think the return type will need to be element()* or an exactly-one(...) will need to be added to the body of the function.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13184</commentid>
    <comment_count>7</comment_count>
    <who name="Carmelo Montanez">carmelo</who>
    <bug_when>2006-12-14 18:30:26 +0000</bug_when>
    <thetext>Nick:

Agreed.  Changed and submitted changes as suggested (added &quot;element()*&quot;) to function&apos;s expected value.  Please close the bug if in agreement.

Thanks,
Carmelo</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13185</commentid>
    <comment_count>8</comment_count>
    <who name="Carmelo Montanez">carmelo</who>
    <bug_when>2006-12-14 18:32:58 +0000</bug_when>
    <thetext>Nick:

Agreed.  Changed and submitted changes as suggested (added &quot;element()*&quot;) to function&apos;s expected value.  Please close the bug if in agreement.

Thanks,
Carmelo</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13203</commentid>
    <comment_count>9</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2006-12-15 14:19:42 +0000</bug_when>
    <thetext>Great. Thanks. Before I close, I don&apos;t know if you want this in a different bug report, but there is the same issue in:

modules-7
modules-9
modules-10
modules-11

The problem is in the function defined in test1-lib.xq

declare function test1:ok ()
{
   &quot;ok&quot;
};


It should have return type string.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13206</commentid>
    <comment_count>10</comment_count>
    <who name="Carmelo Montanez">carmelo</who>
    <bug_when>2006-12-15 15:54:09 +0000</bug_when>
    <thetext>Nick:

This is fine.  I will look at them today.

Carmelo</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13220</commentid>
    <comment_count>11</comment_count>
    <who name="Carmelo Montanez">carmelo</who>
    <bug_when>2006-12-15 18:42:49 +0000</bug_when>
    <thetext>Nick:

Done!

Carmelo</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>