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 4272 - [FS] Type checking fn:data
Summary: [FS] Type checking fn:data
Status: CLOSED INVALID
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Formal Semantics 1.0 (show other bugs)
Version: Proposed Recommendation
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Jerome Simeon
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-23 08:50 UTC by Tim Mills
Modified: 2009-06-22 20:42 UTC (History)
1 user (show)

See Also:


Attachments

Description Tim Mills 2007-01-23 08:50:31 UTC
If, during type checking, it can be determined that fn:data may be applied to a node type which does not have a typed value, which of the following (if any) should occur?

a) err:XPTY0004 be raised at type check time.
b) err:FOTY0012 be raised at type check time.
c) No errors raised at type check time, but err:FOTY0012 be raised during evaluation.

If the correct behaviour is (c), what should be the static return type of fn:data?
Comment 1 Jerome Simeon 2007-02-20 01:04:05 UTC
Tim,

As I understand that case can only occur when the type is a complex type with complex content which is not mixed.

I think in that case there is no inference rule for the 'data on' judgment, and the normal static typing error will be raised, i.e., case (a).

If I am not wrong, this comment does not require any change to our document, is that also your understanding?

Thanks,
- Jerome
Comment 2 Tim Mills 2007-02-20 13:45:41 UTC
Thanks.

The only problem I have with that solution is that it isn't obvious from the signature of fn:data as to why a type checking error is being thrown, since 
the function accepts item()*. 

Were I an end user (who hadn't spends ages pouring over the Formal Semantics!) I might be a little confused and think that the implementation was at fault.

Similar arguments apply to fn:boolean which also accepts item()*, but may throw err:FORG0006 at run time for some inputs.
Comment 3 Jerome Simeon 2007-02-27 16:54:12 UTC
I think part of the reason for this is that the function signature syntax and the sequence type syntax do not allow to precisely describe the typing behavior. This is why we use inference rules in those cases.

I agree could be confusing for a reader, but I'm not sure what to do about it. Would you have any suggestion to improve this?

Thanks,
- Jerome
Comment 4 Jerome Simeon 2007-02-27 17:01:29 UTC
Tim,
The XSLT and XML Query working groups have reviewed this bug, and decided to reclassify it as editorial in order to give you a chance to suggest possible clarifications on this.
Thanks,
- Jerome
Comment 5 Tim Mills 2007-02-27 17:05:46 UTC
Personally, I think I'd just go with raising no errors at type check time, and
raising err:FOTY0012 during evaluation.  At least that way it is consistent
with non-static typing implementations.
Comment 6 Jerome Simeon 2007-02-27 17:46:02 UTC
Tim,
I am suspecting the change you suggest here is more than editorial.
I am reclassifying it back to 'normal' so it is considered by the
working group.
Thanks,
- Jerome
Comment 7 Tim Mills 2007-02-28 07:38:37 UTC
OK thanks.  Here's an example of why doing anything other raising an error at runtime is a "bad thing".

declare function local:if-data($test as item()*, $data as item()*) 
{
  if (fn:boolean($test))
    return fn:data($data);
  else
    return ();
};

This wouldn't pass static type checking because of the differences between the declared argument types of fn:boolean and fn:data, yet at first glance (or without static type checking) is fine.
Comment 8 Christopher Ferris 2007-03-14 18:15:34 UTC
[14:06] scribe: Topic: Issue 4072
[14:07] cferris: http://lists.w3.org/Archives/Public/public-ws-policy/2007Mar/0103.html
[14:08] cferris: relates to http://www.w3.org/Bugs/Public/show_bug.cgi?id=4072 
[14:08] scribe: Daniel: This proposal address the remainder of the existing Issue.
[14:09] scribe: General text on policy references weren't relevant to assertion design. Recognized however, best practice exists for attachments. Semantics don't have dependency on attachment mechanism used.
[14:09] *** ArnaudM has signed off IRC (Quit: CGI:IRC (EOF)).
[14:10] scribe: Rewrote Section 4.1 and added Best Practice.
[14:10] fhirsch3: q+
[14:11] * Zakim sees fhirsch on the speaker queue
[14:12] fhirsch3: q-
[14:12] * Zakim sees no one on the speaker queue
[14:13] scribe: RESOLUTION: Issue 4072 as revised proposal in http://lists.w3.org/Archives/Public/public-ws-policy/2007Mar/0103.html
[14:14] cferris: rrsagent, where am i?
[14:14] RRSAgent: See http://www.w3.org/2007/03/14-ws-policy-irc#T18-14-48
Comment 9 Christopher Ferris 2007-03-14 18:19:55 UTC
OOPS... disregard previous entry... misapplied resolution to the wrong bug id
Comment 10 Michael Dyck 2007-04-28 00:54:51 UTC
(personal response)

Re Comment #0:
If the Static Typing Feature is in effect, and static analysis of a call to fn:data() finds that the static type of the argument prevents the inference of a static type for the call, then I believe a type error [err:XPTY0004] is raised. [XQuery 2.2.3.1 plus FS 7.2.6]

Whether or not the Static Typing Feature is in effect, if static analysis can determine that, if evaluated, the fn:data() call would necessarily be applied to a node without a typed value, then the implementation may raise err:FOTY0012.  [XQuery 2.3.1 plus F+O 2.4]

If the prerequisites for both errors are satisfied, then either or both may be
reported. [XQuery 2.3.1]


Re Comment #2:
Your concern is perhaps valid, but I think the answer to that is helpful error messages and/or user documentation, not a change to the spec.  Conceivably, there could be a special error code for
    "the static type satisfies the signature appearing in F+O,
     but not the more precise typing defined by FS 7.2",
but I suspect there's a very low chance of that being adopted via an erratum against the published Recommendation. It might have more chance in the context of a future version of the spec.


Re Comment #7:
I agree that the example wouldn't pass static type analysis: in general, a call to fn:boolean() or fn:data() will not type-check if its argument is declared as item()*. If, as you suggest, STA *didn't* raise a type error, but evaluation raised err:FOTY0012, that would violate this fairly fundamental requirement of XQuery 2.2.3.1:
    If static type checking raises no errors and assigns a static type T to an
    expression, then execution of the expression on valid input data is
    guaranteed either to produce a value of type T or to raise a dynamic error.
Or as XQuery 2.2.3.2 puts it:
    If the Static Typing Feature is in effect, all type errors are detected
    during static analysis...
(Note that err:FOTY0012 is a type error, not a dynamic error.)

Therefore, I propose that this issue be closed with no change to the specifications.
Comment 11 Michael Dyck 2007-05-03 01:44:26 UTC
The working groups reviewed this issue, and approved the resolution given in Comment #10, namely to close it with no change to the specifications. Consequently, I have marked it INVALID.  Please indicate your acceptance of this resolution by marking it CLOSED.
Comment 12 Michael Dyck 2009-06-22 20:42:46 UTC
After two years with no response from the original reporter,
I am marking this issue CLOSED.  Feel free to reopen it
if you disagree with this outcome.