Catch Block Scope, Broken Different in IE9pr3

G

Garrett Smith

In ECMAScript, a catch block augments the current scope chain by pushing
a new Object to the front of the scope chain.

However, official versions of JScript up to and including JScript 5.8
don't do that. Instead, when entering a catch block, these versions of
JScript add the catch block's parameter to the containing scope.

This was fixed in IE9's JScript engine, "JScript 0.9", using, however, I
have noticed that functions defined in the catch block don't get the
catch block's scope that they're defined in.

This is shown in the example below. When augmented is called, `ex` can't
be accessed.

<!doctype html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>test catch scope</title>
</head>
<body>
<script type="text/javascript">
try {
var ex = 12;
x; // throw a ReferenceError
} catch(ex) {
alert(ex.name);
var augmented = function() {
alert(ex);
};
augmented();
}
</script>
</body>
</html>

IE9 Results: "ReferenceError", "12".

Function `augmented` isn't getting the scope chain from the catch block.

Garrett
 
J

jdalton

Nice find.
Did you report this bug?
The IE dev team has been responsive to my bug reports... ;D
 
G

Garrett Smith

Nice find.
Did you report this bug?
The IE dev team has been responsive to my bug reports... ;D

Nope. Been busy. For example, today, my cat peed and pooped on my bed.
What a nice boy.

BTW where do you report IE bugs these days? connect.microsoft.com?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top