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 4024 - ST-WhereExpr001 should not be expected to fail?
Summary: ST-WhereExpr001 should not be expected to fail?
Status: RESOLVED INVALID
Alias: None
Product: XML Query Test Suite
Classification: Unclassified
Component: XML Query Test Suite (show other bugs)
Version: 1.0.2
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Frans Englich
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-28 07:27 UTC by Per Bothner
Modified: 2007-10-09 13:23 UTC (History)
0 users

See Also:


Attachments

Description Per Bothner 2006-11-28 07:27:18 UTC
ST-WhereExpr001 is described as "Test 'where' clause with heterogenous sequences. First item is a node."  The XQTSCatalog.xml says this is expected to fail with FORG0006.  But the specification says we take the Effective boolean value of the value of the order expression, and "2.4.3 Effective Boolean Value" says:
"If [the operand of fn:boolean] is a sequence whose first item is a node, fn:boolean returns true."  So I don't see why the testcase shoudl fail.

Perhaps a cut-and-paste error or similar confusion?  ST-WhereExpr001 is the same, except that the first item if the sequence is "value" [sic], such *should* be an error.
Comment 1 Marc Van Cappellen 2006-11-28 07:48:59 UTC
fwiw, I believe ST-WhereExpr001 can fail against the static typing rules. See for example bug 2943 and bug 2942.
Comment 2 Per Bothner 2006-11-28 08:20:06 UTC
(In reply to comment #1)
> fwiw, I believe ST-WhereExpr001 can fail against the static typing rules.

True, but that is because the static typing rules for fn:boolean do not match the informal description in "Functions and Operators".  So is the error in:
(a) Functions and Operators - and the main XQuery specification; or
(b) the Formal Semantics - and ST-WhereExpr001?

Pity the inconsistency wasn't fixed earlier.


Comment 3 Michael Kay 2006-11-28 09:18:56 UTC
I think this is a Static Typing test. Static typing often fails where dynamic typing succeeds. 
Comment 4 Michael Kay 2006-11-28 09:24:03 UTC
>True, but that is because the static typing rules for fn:boolean do not match
the informal description in "Functions and Operators". 

I don't understand this comment. Section 15.1.1 in F+O doesn't attempt to describe the static typing rules for fn:boolean, even informally. It explicitly states that the static typing rules are to be found in the Formal Semantics document.
Comment 5 Per Bothner 2006-11-28 18:09:26 UTC
The static typing rules are not supposed to define a separate language.  They are supposed to defined a set of computable (and hence conservative) rules for staticing determing whether an XQuery program is type-correct.  Because of the limits of computability, and because we want to be conservative, sometimes static typing will reject a program that works fine.  However, that is not the goal: The goal is that if we had perfect computability, then static typing would reject a program if and only if there is some set of inputs that would cause the program to fail at runtime.

The distinction between the dynamic and static semantics for fn:boolean seems to violate that goal.  Even for this trivial program it is unclear if it is valid:
  fn:boolean(<a/>, 1)

Now I can see the efficiency argument for not having to test every item in a sequence.  One solution is to make unspecified the result of fn:boolean on a hybrid sequence starting with a node - allow an implementation to yield either true or an error,

At the very least the test-case needs to be fixed too allow it to not fail.
Comment 6 Michael Rys 2006-11-29 00:24:32 UTC
There is a bit of "standard" history behind that behaviour. There is really no good semantic meaning for fn:boolean on heterogeneous sequences. E.g., fn:boolean((<a/>, false()))... should that be true, false? So some people wanted this to be an error (especially since it is also being used in the context of predicates as the implied semantics). Other people that have runtime semantics, did not want to evaluate 2000 values before hitting the heterogeneity and wanted a more performant semantics. So we decided, as a compromise, to make this a static error, but have efficient, dynamic semantics for the implementations, that do not do static analysis.
Comment 7 Per Bothner 2006-12-01 08:47:00 UTC
(In reply to comment #6)
That makes sense and that is why I suggested in #5 to make the dynamic semantics of fn:boolean((NODE, .., ATOMIC ...)) unspecified, allowing implementations to return either true or error.

But in any case, the testsuite should be fixed to allow but not require an error.
Comment 8 Frans Englich 2007-09-12 10:37:54 UTC
Since ST-WhereExpr001 is a test for the optional Static Typing Feature, it means at least to me that implementations not implementing the Static Typing Feature, should not run it.

By that my conclusion is that the output is irrelevant, since static typing implementations must trigger a static type error(as per mrys' comment).

Per, does your implementation support the Static Typing Feature?
Comment 9 Per Bothner 2007-09-13 05:29:22 UTC
(In reply to comment #8)
> Since ST-WhereExpr001 is a test for the optional Static Typing Feature, it
> means at least to me that implementations not implementing the Static Typing
> Feature, should not run it.

The XQTSCataLog.xml file describes the scenario as "runtime-error".

I don't see anything in the XQTS documenttaion or in XQTSCatalog.xml to say that implementations not implementing the Static Typing should not run this test, except maybe keying off the StaticTyping  directory in the FilePath.  That seems a bit of a kludge.

> By that my conclusion is that the output is irrelevant, since static typing
> implementations must trigger a static type error(as per mrys' comment).
> 
> Per, does your implementation support the Static Typing Feature?

No - it does some ad-hoc static typing, so it catches some type errors at compile time.
Comment 10 Frans Englich 2007-09-13 07:40:20 UTC
I agree that the documentation doesn't say that tests in the "Optional Features" group mustn't be run. Have a look at:

http://www.w3.org/XML/Query/test-suite/XQTSReportSimple.html

For several of the optional features the fields are white, meaning they are untested for that implementation. For instance, the implementation BaseX hasn't run the tests for Schema Import Feature, and Anglo doesn't support the Static Typing Feature.

The optional feature-tests are designed for testing those optional features, so if one doesn't implement it, they will obviously fail. For instance, Constr-compelem-constrmod-1 doesn't allow XQST0009, which an implementation that doesn't support Schema Validation, will raise.

Same goes for ST-WhereExpr001. An implementation implementing the static typing feature, must raise FORG0006, and that's what the test tests.

For my own driver I do this by letting the code that reads the catalog file, skip the whole sub-tree if a category is encountered whose name is a category Patternist doesn't support.
Comment 11 Frans Englich 2007-10-01 10:18:03 UTC
I'm closing this report, since ST-WhereExpr001, which tests optional static typing, was run using a non-static typing implementation(see comment #10).

If this resolution is satisfactory, feel free to change status to CLOSED. Otherwise reopen this report. If no feedback is given within two weeks, status will be set to CLOSED.
Comment 12 Nick Jones 2007-10-09 13:23:15 UTC
Just an extra comment: If it is deemed that this test should fail because of the static typing rule in the formal semantics, then surely the error code should be XPTY0004 rather than FORG0006? The same goes for ST-WhereExpr002, and statictyping-7