This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 3829 - Static typing of function declarations
Summary: Static typing of function declarations
Status: RESOLVED FIXED
Alias: None
Product: XML Query Test Suite
Classification: Unclassified
Component: XML Query Test Suite (show other bugs)
Version: 1.0.1
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Carmelo Montanez
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-13 14:36 UTC by Nick Jones
Modified: 2006-12-15 18:42 UTC (History)
0 users

See Also:


Attachments

Description Nick Jones 2006-10-13 14:36:12 UTC
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
Comment 1 Nick Jones 2006-10-13 14:57:04 UTC
Same issues in

default_namespace-003
default_namespace-005
default_namespace-006
default_namespace-016
default_namespace-017
Comment 2 Carmelo Montanez 2006-12-12 22:18:43 UTC
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
Comment 3 Nick Jones 2006-12-13 17:08:15 UTC
We are currently throwing a err:XPTY0018 "a type error if the result of the last step in a path expression contains both nodes and atomic values." 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'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.

Comment 4 Frans Englich 2006-12-13 18:07:38 UTC
I agree default_namespace-016 has a type error, but I don't think it's XPTY0018.

XPTY0018 is raised when the last step contains a mixture. The last step in default_namespace-016 has type item()*. It's hasn'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't be statically type checked in a sound way.

I suggest fixing the test by adding XPTY0004 as an alternative baseline.
Comment 5 Carmelo Montanez 2006-12-14 15:40:38 UTC
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
Comment 6 Nick Jones 2006-12-14 16:03:45 UTC
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.
Comment 7 Carmelo Montanez 2006-12-14 18:30:26 UTC
Nick:

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

Thanks,
Carmelo
Comment 8 Carmelo Montanez 2006-12-14 18:32:58 UTC
Nick:

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

Thanks,
Carmelo
Comment 9 Nick Jones 2006-12-15 14:19:42 UTC
Great. Thanks. Before I close, I don'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 ()
{
   "ok"
};


It should have return type string.
Comment 10 Carmelo Montanez 2006-12-15 15:54:09 UTC
Nick:

This is fine.  I will look at them today.

Carmelo
Comment 11 Carmelo Montanez 2006-12-15 18:42:49 UTC
Nick:

Done!

Carmelo