From f9739eaf80c7444545dec9b77861d8496ad20a89 Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Sat, 2 Feb 2013 00:27:05 +0200 Subject: [PATCH] catch binding test cases, illustrate current bug --- ...ing.js => test-dev-bug-catch-binding-1.js} | 0 testcases/test-dev-bug-catch-binding-2.js | 30 +++++++++++++++++++ 2 files changed, 30 insertions(+) rename testcases/{test-dev-bug-catch-binding.js => test-dev-bug-catch-binding-1.js} (100%) create mode 100644 testcases/test-dev-bug-catch-binding-2.js diff --git a/testcases/test-dev-bug-catch-binding.js b/testcases/test-dev-bug-catch-binding-1.js similarity index 100% rename from testcases/test-dev-bug-catch-binding.js rename to testcases/test-dev-bug-catch-binding-1.js diff --git a/testcases/test-dev-bug-catch-binding-2.js b/testcases/test-dev-bug-catch-binding-2.js new file mode 100644 index 00000000..e04c9ccf --- /dev/null +++ b/testcases/test-dev-bug-catch-binding-2.js @@ -0,0 +1,30 @@ +/*=== +closure throw +closure throw +closure throw +===*/ + +/* This was broken at an early point. Catch binding variable would be mapped + * to a certain register for the duration of the catch clause. A closure + * created from the catch clause would work incorrectly once the original + * invocation exited the catch clause. + */ + +function f() { + var e = 123; + var func; + + try { + throw 'throw'; + } catch (e) { + func = function() { print('closure', e); } + func(); + } + + func(); + + return func; +} + +f()(); +