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 16370 - [XQ30] Does a TryCatch expression catch a type error raised during the static analysis phase?
Summary: [XQ30] Does a TryCatch expression catch a type error raised during the static...
Status: RESOLVED INVALID
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3.0 (show other bugs)
Version: Working drafts
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-14 15:59 UTC by Ghislain Fourny
Modified: 2012-06-12 16:54 UTC (History)
2 users (show)

See Also:


Attachments

Description Ghislain Fourny 2012-03-14 15:59:59 UTC
In section 2.3.1 (Kinds of errors) it is said that "a type error may be raised during the static analysis phase or the dynamic evaluation phase."

Section 3.15 (TryCatch Expressions) says

1. "A try/catch expression catches dynamic errors and type errors raised during dynamic evaluation for expressions that are lexically contained within the try clause,"
2. "if the target expression raises a dynamic error or a type error, [catch clause evaluated]" (with no further precision on type error)
3. "Static errors are not caught by the try/catch expression."

I am a bit unsure about when type errors are caught, as I could not find a specific sentence for type errors raised statically (maybe I just missed it).

If we distinguish between type errors raised statically and those raised dynamically, it might lead to a behavior which is hard to predict within an implementation and between implementations.

Should we make a try catch expression also catch type errors when they are raised during the static analysis phase (in which case, as a rule of thumb, I guess an optimizer could replace the trycatch expression with the matching catch expression)?
Comment 1 Michael Kay 2012-03-14 17:48:32 UTC
I think the rule is that if type errors are raised statically then you can't catch them.

I notice that XSLT 3.0 is not clear about whether xsl:try/xsl:catch catches type errors. It only speaks of dynamic errors being caught.

We already have a lack of interoperability caused by allowing implementations to decide whether to raise type errors statically or dynamically. I don't think try/catch makes this significantly worse. Anyone who catches type errors and tries to recover from them needs to know that this won't work on an implementation that detects them statically.
Comment 2 Jonathan Robie 2012-05-07 19:15:25 UTC
I agree with Mike Kay's interpretation in Comment #1.

See also the discussion in Bug 10848.
Comment 3 Jonathan Robie 2012-06-07 22:20:19 UTC
Ghislain - have we answered your question, or is there an outstanding issue here that needs to be resolved?
Comment 4 Jonathan Robie 2012-06-12 16:50:36 UTC
The WG believes the spec is clear on this point.
Comment 5 Ghislain Fourny 2012-06-12 16:54:22 UTC
Yes, it makes sense. Thanks!