<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>1655</bug_id>
          
          <creation_ts>2005-07-16 00:41:34 +0000</creation_ts>
          <short_desc>[FS] need examples of when to raise a type error</short_desc>
          <delta_ts>2005-07-26 15:34:52 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Formal Semantics 1.0</component>
          <version>Last Call drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows 2000</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Fred Zemke">fred.zemke</reporter>
          <assigned_to name="Jerome Simeon">simeon</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>4739</commentid>
    <comment_count>0</comment_count>
    <who name="Fred Zemke">fred.zemke</who>
    <bug_when>2005-07-16 00:41:35 +0000</bug_when>
    <thetext>4. Expressions
Under &quot;Static type analysis&quot;, the discussion of when to raise a
type error is difficult to understand.
It would help to work through the example in more detail.
Consider x/title, where
$x is statically known to have no children.  
I have not been able to figure out how the rules in the rest
of Formal Semantics would actually analyze this, but there
seem to be two possibilities:

1. There are rules that infer 
statEnv |- $x/title : empty.  But in that case, there are
static type rules that apply to the expression $x/title,
by hypothesis.  The principle that &quot;the absence of an applicable 
static rule indicates an error&quot; does not seem to apply.  
Instead, it looks like you want the following inference:

statEnv |- Expr : empty
not (Expr is empty sequence expression () or ... )
--------------------------------------------------
statEnv |- Expr raises typeError

2. The other possibility is that the other rules in Formal
Semantics are unable to draw any inference of the form
statEnv |- $x/title : Type.  Now the principle &quot;the absence of an
applicable static rule indicates an error&quot; does apply.  However,
the inference now seems irrelevant because there is no way to
reach the first hypothesis, statEnv |- $x/title : Type.

Scenario 1 is certainly possible (though I don&apos;t know if 
$x/title is an instance of it).  For example, the expressions

((), ())

if $a = $b then () else ()

let $i := () return $i

all have applicable static type rules whose ultimate conclusion is
that the type is empty.  I don&apos;t know if Scenario 2 is possible
or not; perhaps $x/title is an example.

I think it would help to revise this section to consider these
scenarios explicitly, including worked examples, and possibly 
replace the inference with the one suggested above.  If Scenario 
2 is not possible, then a statement that 
(for all Expr) (there exists Type) [statEnv |- Expr : Type]
would be very helpful.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5199</commentid>
    <comment_count>1</comment_count>
    <who name="Fred Zemke">fred.zemke</who>
    <bug_when>2005-07-25 19:38:37 +0000</bug_when>
    <thetext>See comment #1605, additional comment #1, list item 3, in which it is stated
that there are indeed expressions for which no type can be deduced.  
I conclude that there are two scenarios for static type errors:

1. an expression for which no formal type can be deduced

2. an expression for which &quot;statEnv |- Expr : empty&quot; can be deduced, and
Expr is not one of the three permitted kinds of expressions of empty type.

Note that these two scenarios cannot be reduced to each other.

Accordingly, the fix for section 4 &quot;Expressions&quot; is to describe both of these
scenarios separately.  For scenario 1, there is no inference to state, since
the formal language of inferences is not powerful enough to express the 
concept, &quot;statEnv | not (for all Type) [Expr : Type]&quot;.  And even if the 
language was extended to include this kind of judgment, you would have to
add the whole machinery necessary to draw conclusions of that sort.
Rather, this case is
handled through the definition of the inference engine, which should say 
that the objective is to either conclude &quot;statEnv |- Expr : Type&quot; for 
some particular Type, given the user&apos;s Expr and initial statEnv, or else to
conclude that there is no such Type.

For scenario 2, it is possible to state an inference, but it is not the one
shown in the specification.  The correct inference is

statEnv |- Expr : empty
not (Expr is empty sequence expression () or ... )
--------------------------------------------------
statEnv |- Expr raises typeError</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5212</commentid>
    <comment_count>2</comment_count>
    <who name="Jerome Simeon">simeon</who>
    <bug_when>2005-07-26 15:06:30 +0000</bug_when>
    <thetext>Fred,

We have had a separate suggestion from Michael Dyck to use the second
alternative you suggest, so I think we should use that one.

Thanks,
- Jerome</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5218</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Rys">mrys</who>
    <bug_when>2005-07-26 15:34:17 +0000</bug_when>
    <thetext>The working group decided to accept your additional comment 1 (correction to 
Jerome&apos;s comment).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5219</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Rys">mrys</who>
    <bug_when>2005-07-26 15:34:52 +0000</bug_when>
    <thetext>We close the bug since we accepted the proposal.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>