<?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>3717</bug_id>
          
          <creation_ts>2006-09-13 11:55:09 +0000</creation_ts>
          <short_desc>Cardinality inference for &apos;cast as&apos; should take operand into account</short_desc>
          <delta_ts>2006-09-27 09:46:11 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Formal Semantics 1.0</component>
          <version>Candidate Recommendation</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>WONTFIX</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>
          
          <blocked>3651</blocked>
    
    <blocked>3686</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Frans Englich">frans.englich</reporter>
          <assigned_to name="Jerome Simeon">simeon</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>11646</commentid>
    <comment_count>0</comment_count>
    <who name="Frans Englich">frans.englich</who>
    <bug_when>2006-09-13 11:55:09 +0000</bug_when>
    <thetext>Recently, there has been reports on tests in the XQTS which uses cast expressions as operands to expressions that expects exactly-one. An example:

        fn:dateTime(xs:date(&quot;1999-12-31&quot;), xs:time(&quot;12:00:00&quot;))

This query contains two type errors, because the operands are typed as xs:date?/xs:time? while xs:date/xs:time is expected.

One runs easily into this problem, because as soon one wants to specify a literal using a constructor function, one gets a type error, which to me seems counter intuitive.

Therefore, I suggest to change the inference rule for &apos;cast as&apos; to have as cardinality exactly-one if its operand&apos;s cardinality is exactly-one(that is, whether the &apos;?&apos; is specified is ignored for computing the static type).

See:
http://www.w3.org/Bugs/Public/show_bug.cgi?id=3686
http://www.w3.org/Bugs/Public/show_bug.cgi?id=3651</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>11670</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Rys">mrys</who>
    <bug_when>2006-09-13 20:28:11 +0000</bug_when>
    <thetext>While special casing the inference solves the particular problem, often the arguments to fn:dateTime() will be provided using some expressions that will infer optionality in their static type. So this proposal will only solve a small subset and will not address the general issue.

The general issue should be (and has been) resolved by widening the accepted type range for fn:dateTime().

Best regards
Michael</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>11772</commentid>
    <comment_count>2</comment_count>
    <who name="Frans Englich">frans.englich</who>
    <bug_when>2006-09-15 09:55:09 +0000</bug_when>
    <thetext>I agree the proposed change is a patch in the traditional sense. However, I think it&apos;s a large patch. That is, that most of these problems are caused by cast expressions.

I have a hard time understanding relaxing signatures. That static typing decreases usability is a consequence -- a trade off. The point of static typing is to reduce branching/possibilities in the implementation, and relaxing a signature is doing the opposite.

I&apos;m not opposed to relaxing fn:dateTime, I just have a hard time understanding it, since it to me seems contradictory to why people wanted static typing in the first place.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>11842</commentid>
    <comment_count>3</comment_count>
    <who name="Jerome Simeon">simeon</who>
    <bug_when>2006-09-18 23:48:17 +0000</bug_when>
    <thetext>It seems that if users are able to write functions like that:

xs:date(if (cond()) then () else &quot;1999-12-31&quot;)

then static typing must be consistent with the dynamic semantics.

Another example is when using arithmetics:

declare function mycast($floatvalue as xs:float?) as xs:decimal? {
  xs:decimal($floatvalue * 0.2E-5)
};

So either such queries should type check (which is what currently happens), or someone has to decide that constructors functions cannot take an empty sequence.

Either way, I think either change is too big for the stage of development XQuery
is right now.

- Jerome</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12037</commentid>
    <comment_count>4</comment_count>
    <who name="Jerome Simeon">simeon</who>
    <bug_when>2006-09-26 14:08:16 +0000</bug_when>
    <thetext>Frans,
Thanks for your comment.
The XSLT and XML Query Working groups have discussed this issue
and decided that it was too late in the process to revisit
the decisions in that area, and to close the bug with
no further action.
Please let us know if you can live with that decision.
Best,
- Jerome
On behalf of the XSLT and XML Query WGs</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>