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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>19359</bug_id>
          
          <creation_ts>2008-06-02 09:31:25 -0700</creation_ts>
          <short_desc>JavaScriptCore behaves differently from FF2/3 and IE when handling context in catch statement</short_desc>
          <delta_ts>2008-08-03 02:58:37 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://wiki.ecmascript.org/doku.php?id=es3.1:catch_clause_context_specification</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="Feng Qian">ian.eng.webkit</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ggaren</cc>
    
    <cc>oliver</cc>
    
    <cc>zwarich</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>82123</commentid>
    <comment_count>0</comment_count>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2008-06-02 09:31:25 -0700</bug_when>
    <thetext>The link describes the behaviors of FF and IE, and here is the example code:
function foo() {
  this.x = 11;
}
 
x = &quot;global.x&quot;;

try {
  throw foo;
} catch(e) {
  print(x) // Should print &quot;global.x&quot;
  e();
  print(x) // Should add x to e
           // (Both IE and Firefox modify the global x)
}

print(x);  // Should print &quot;global.x&quot;. IE and Firefox both print 11

Although the spec says the last print statement should print &apos;global.x&apos;, but
FF (&gt;1.5) and IE print out &apos;11&apos;. According to Brendan Eich, ES4 will follow IE behavior.

Should KJS change its implementation? I don&apos;t know any broken websites due to this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82157</commentid>
    <comment_count>1</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2008-06-02 13:51:16 -0700</bug_when>
    <thetext>Is this reduction missing a definition of e()?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82159</commentid>
    <comment_count>2</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2008-06-02 13:57:48 -0700</bug_when>
    <thetext>I don&apos;t think so.  &apos;e&apos; is the name of the exception thrown.  it should be the same as calling foo() I guess. </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82160</commentid>
    <comment_count>3</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2008-06-02 14:18:34 -0700</bug_when>
    <thetext>throw foo; results in foo being set as the exception value e.

I&apos;m not sure how we can mimic the firefox/ie behaviour as it makes no sense in the context of the spec.  Afaict the only way you could hope to achieve the behaviour that they have would be to not introduce the requisite dynamic scope, but then i&apos;m not sure what would happen if you had a with block inside a catch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84647</commentid>
    <comment_count>4</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2008-06-28 03:13:17 -0700</bug_when>
    <thetext>Okay, this issue is just that ie/firefox are using an activation rather than a real object (which contradicts the specs, but hey) -- I say we match their behaviour.  Not only does it help compatibility (in a bizarre edge case at least) but it makes it possible to actually optimise in a catch block, something that was not technically possible before.

Possibly worth test the behaviour of this as well though
try {
  throw foo;
} catch(e) {
  with ({}) {
    print(x) // Should print &quot;global.x&quot;
    e();
    print(x) // Should add x to e
              // (Both IE and Firefox modify the global x)
  }
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87715</commentid>
    <comment_count>5</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2008-08-03 02:58:37 -0700</bug_when>
    <thetext>Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	JavaScriptCore/ChangeLog
	M	JavaScriptCore/VM/CodeBlock.cpp
	M	JavaScriptCore/VM/CodeGenerator.cpp
	M	JavaScriptCore/VM/CodeGenerator.h
	M	JavaScriptCore/VM/Machine.cpp
	M	JavaScriptCore/VM/Opcode.h
	M	JavaScriptCore/kjs/JSStaticScopeObject.cpp
	M	JavaScriptCore/kjs/JSStaticScopeObject.h
	M	JavaScriptCore/kjs/nodes.cpp
	M	LayoutTests/ChangeLog
	A	LayoutTests/fast/js/resources/static-scope-object.js
	A	LayoutTests/fast/js/static-scope-object-expected.txt
	A	LayoutTests/fast/js/static-scope-object.html
Committed r35533

</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>