<?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>9600</bug_id>
          
          <creation_ts>2010-04-27 18:26:33 +0000</creation_ts>
          <short_desc>[XQuery 1.1] Importing schema with a simple type conflicting with a function declaration.</short_desc>
          <delta_ts>2010-06-15 18:38:31 +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>XQuery 3.0</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</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="Oliver Hallam">oliver</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>jim.melton</cc>
    
    <cc>jmdyck</cc>
    
    <cc>mike</cc>
          
          <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>35270</commentid>
    <comment_count>0</comment_count>
    <who name="Oliver Hallam">oliver</who>
    <bug_when>2010-04-27 18:26:33 +0000</bug_when>
    <thetext>Consider a schema in namespace &quot;http://www.example.org/&quot; that defines a type example:foo.

Consider the following module, also in namespace &quot;http://www.example.org/&quot;.



declare module namespace example=&quot;http://www.example.org/&quot;;

declare function example:foo($x as item())
{
$x
}


This function declaration is valid, as the schema has not been imported and there is no conflict with any in scope function.

Now consider a query which imports both this module, and the schema:


import module namespace example=&quot;http://www.example.org/&quot;;
import schema namespace example=&quot;http://www.example.org/&quot;;

example:foo(1)


Clearly we have a problem here; does the example:foo function call refer to the constructor or the user defined function.

Surely there should have been an error raised when importing the module/schema.

The spec makes it quite clear (in section 4.17) that an XQST0034 error should be raised if the function was declared when the schema was in scope, although this is not the case here (as the schema was not imported in the module)

The equivalent rules for this error when importing a module (section 4.12) state:

It is a static error if the expanded QName and arity of a function declared in an imported module are respectively equal to the expanded QName and arity of a function declared in the importing module or in another imported module (even if the declarations are consistent) [err:XQST0034]

Since the schema constructor is not &quot;a function declared in the importing module or in another imported module&quot; this does not hold either.

I suggest that the above text should be modified to include also the case where &quot;an imported function has arity 1 and has an expanded QName which is equal to the expanded QName of an atomic type defined in a schema imported by the importing module&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35304</commentid>
    <comment_count>1</comment_count>
    <who name="Oliver Hallam">oliver</who>
    <bug_when>2010-04-29 15:21:51 +0000</bug_when>
    <thetext>There is a similar problem when importing a schema (in the fn namespace) with an atomic type that conflicts with the name of one of the built in functions.  Since these functions are never declared the error condition does not apply.

(On a side note is it intentional that a module can be written in the fn namespace, but the module cannot contain any functions?)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35305</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2010-04-29 15:34:29 +0000</bug_when>
    <thetext>Arguably we should rely more on declarative statements of constraints, like this one in 2.1.1: &quot;Each function is uniquely identified [within the static context] by its expanded QName and its arity (number of parameters).&quot;, and worry less about enumerating all the situations that can cause the constraint to be violated. Though it makes a useful test case for implementations.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35313</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2010-04-29 17:31:39 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; 
&gt; I suggest that the above text should be modified to include also the case where
&gt; &quot;an imported function has arity 1 and has an expanded QName which is equal to
&gt; the expanded QName of an atomic type defined in a schema imported by the
&gt; importing module&quot;.

Rather than going to that level of detail, we could use the concept of &apos;constructor functions&apos;, e.g., add a clause about functions &quot;implicitly defined by a schema import in the importing module&quot;.

Another approach would be to avoid listing the various places where a function could come from, and just refer to the &apos;function signatures&apos; component of the static context.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35314</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2010-04-29 17:56:24 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; Arguably we should rely more on declarative statements of constraints, like
&gt; this one in 2.1.1: &quot;Each function is uniquely identified [within the static
&gt; context] by its expanded QName and its arity (number of parameters).&quot;, and
&gt; worry less about enumerating all the situations that can cause the constraint
&gt; to be violated.

So then we&apos;d just say something like &quot;It is a static error [err:XQST0034] if any situation causes that constraint to be violated.&quot; ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35559</commentid>
    <comment_count>5</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2010-05-11 16:24:48 +0000</bug_when>
    <thetext>I propose we add an error to the section on constructors:

3.14.5 Constructor Functions

For every atomic type in the in-scope schema types (except xs:NOTATION
and xs:anyAtomicType, which are not instantiable), a constructor
function is implicitly defined.

&lt;add&gt;
If a constructor function has the same name and arity as an existing
function in the function signatures, a static error [err:####] is
raised.
&lt;/add&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35570</commentid>
    <comment_count>6</comment_count>
    <who name="Oliver Hallam">oliver</who>
    <bug_when>2010-05-11 18:32:43 +0000</bug_when>
    <thetext>Does this entirely cover us?

If we import the schema before the module first then do the function signatures yet include the ones from the module?

It might be worth also changing (XQ 4.12)

It is a static error if the expanded QName and arity of a function declared in
an imported module are respectively equal to the expanded QName and arity of a
function declared in the importing module or in another imported module (even
if the declarations are consistent) [err:XQST0034]

to:

It is a static error if the expanded QName and arity of a function declared in
an imported module are respectively equal to the expanded QName and arity of an existing function in the function signatures (even if the declarations are consistent) [err:XQST0034]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35578</commentid>
    <comment_count>7</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2010-05-11 21:26:09 +0000</bug_when>
    <thetext>(In reply to comment #6)

&gt; It might be worth also changing (XQ 4.12)
&gt; 
&gt; It is a static error if the expanded QName and arity of a function declared in
&gt; an imported module are respectively equal to the expanded QName and arity of a
&gt; function declared in the importing module or in another imported module (even
&gt; if the declarations are consistent) [err:XQST0034]
&gt; 
&gt; to:
&gt; 
&gt; It is a static error if the expanded QName and arity of a function declared in
&gt; an imported module are respectively equal to the expanded QName and arity of an
&gt; existing function in the function signatures (even if the declarations are
&gt; consistent) [err:XQST0034]

I agree.

I suspect these two changes should be sufficient.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35592</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2010-05-11 23:06:46 +0000</bug_when>
    <thetext>The word &quot;existing&quot; seems to imply a particular order of processing. It&apos;s surely possible to express the error as a constraint that doesn&apos;t depend on order of processing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36187</commentid>
    <comment_count>9</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2010-06-15 15:00:45 +0000</bug_when>
    <thetext>(In reply to comment #8)
&gt; The word &quot;existing&quot; seems to imply a particular order of processing. It&apos;s
&gt; surely possible to express the error as a constraint that doesn&apos;t depend on
&gt; order of processing.


I think the existing text for module import does this nicely. I think we should simply echo this in the text for schema import, using the same language and the same error code to emphasize the parallelism between the two:

4.12 Module Import (current)

It is a static error if the expanded QName and arity of a function
declared in an imported module are respectively equal to the expanded
QName and arity of a function declared in the importing module or in
another imported module (even if the declarations are consistent)
[err:XQST0034].

4.11 Schema Import (proposed)

It is a static error if the expanded QName and arity of a
&lt;diff&gt;constructor function&lt;/diff&gt; are respectively equal to the
expanded QName and arity of a function declared in the importing
module or in another imported module (even if the declarations are
consistent) [err:XQST0034].</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36197</commentid>
    <comment_count>10</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2010-06-15 18:38:31 +0000</bug_when>
    <thetext>The solution in comment #9 was adopted in today&apos;s telcon.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>