From 75168c7f574362ad3d294583c2ecec20e8694f8a Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Sun, 7 Sep 2008 15:11:26 +0000 Subject: [PATCH] bugfix when exception in function --- Test.hx | 1 + haxelib.xml | 2 +- hscript/Interp.hx | 8 +++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Test.hx b/Test.hx index 8d89c76..5726b70 100644 --- a/Test.hx +++ b/Test.hx @@ -56,6 +56,7 @@ class Test { test("var t = 0; for( x in 1...10 ) t += x; t",45); test("var t = 0; for( x in new IntIter(1,10) ) t +=x; t",45,{ IntIter : IntIter }); test("var x = 1; try { var x = 66; throw 789; } catch( e : Dynamic ) e + x",790); + test("var x = 1; var f = function(x) throw x; try f(55) catch( e : Dynamic ) e + x",56); } } \ No newline at end of file diff --git a/haxelib.xml b/haxelib.xml index cf6866c..53c6289 100644 --- a/haxelib.xml +++ b/haxelib.xml @@ -1,5 +1,5 @@ haXe Script is a scripting engine for a subset of the haXe language - Added new, throw, try/catch, hex numbers and ... operator support + Fixed bug in interpreter when catching exception in function \ No newline at end of file diff --git a/hscript/Interp.hx b/hscript/Interp.hx index aaef612..86b8698 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -283,7 +283,13 @@ class Interp { me.locals = me.duplicate(capturedLocals); for( i in 0...params.length ) me.locals.set(params[i],{ r : args[i] }); - var r = me.exprReturn(fexpr); + var r; + try { + r = me.exprReturn(fexpr); + } catch( e : Dynamic ) { + me.locals = old; + throw e; + } me.locals = old; return r; };