W3C home > Mailing lists > Public > public-qt-comments@w3.org > September 2010

[Bug 10848] New: [XQuery11] Statically detecting errors in try/catch and conditional expressions

From: <bugzilla@jessica.w3.org>
Date: Thu, 30 Sep 2010 12:58:50 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-10848-523@http.www.w3.org/Bugs/Public/>
http://www.w3.org/Bugs/Public/show_bug.cgi?id=10848

           Summary: [XQuery11] Statically detecting errors in try/catch
                    and conditional expressions
           Product: XPath / XQuery / XSLT
           Version: Member-only Editors Drafts
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XQuery 1.1
        AssignedTo: jonathan.robie@redhat.com
        ReportedBy: oliver@cbcl.co.uk
         QAContact: public-qt-comments@w3.org
             Group: XSLXQuery_WG


Section 3.14 states (for try/catch expressions):

If an error found in a try clause can be detected statically, an implementation
is free to raise a static error. Static errors are not caught by the try/catch
expression.


Which differs from the rules in IfExpression

Conditional expressions have a special rule for propagating dynamic errors. If
the effective value of the test expression is true, the conditional expression
ignores (does not raise) any dynamic errors encountered in the else-expression.
In this case, since the else-expression can have no observable effect, it need
not be evaluated. Similarly, if the effective value of the test expression is
false, the conditional expression ignores any dynamic errors encountered in the
then-expression, and the then-expression need not be evaluated.

As for the definition of dynamic error:

[Definition: A dynamic error is an error that must be detected during the
dynamic evaluation phase and may be detected during the static analysis phase.
Numeric overflow is an example of a dynamic error. ]

[Definition: A static error is an error that must be detected during the static
analysis phase. A syntax error is an example of a static error.]

So, a dynamic error may be detected statically; this is different from a static
error.

This means that the following query:

if ($test)
then (1 div 0)
else false()

is not allowed to raise the error until runtime (as it is a dynamic error)

but

if ($test)
then try {1 div 0 } catch * { true() }
else false()

is allowed to raise a division by zero error statically, as it is raised as a
static error.  By catching a possible error, you allow it to be raised!


There are two ways to resolve this:

1. Always allow the error to be raised.  This requires a change to the text of
IfExpr, TypeswitchExpr and SwitchExpr to state that dynamic errors detected
statically may be raised.

2. Prevent the error from being raised, unless it is garuanteed to be raised. 
This requires a change to the text in 3.14 from "If an error found in a try
clause can be detected statically, an implementation is free to raise a static
error" to "If a static error is found in a try clause, an implementation is
free to raise the static error".  However after this change this sentence
becomes redundant to the following sentence.

I suspect (2) is the desired behaviour.


Finally, an editorial point - the phrase "is free to" in this sentence should
be replaced with "may".  Although if the change made in (2) is made this should
probably become "should".

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
Received on Thursday, 30 September 2010 12:58:52 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:06 GMT