Browse Source

[lua] fix ctx.in_loop_try specification position

Justin Donaldson 8 years ago
parent
commit
ced4ac3bb7
2 changed files with 19 additions and 1 deletions
  1. 1 1
      src/generators/genlua.ml
  2. 18 0
      tests/unit/src/unit/issues/Issue6349.hx

+ 1 - 1
src/generators/genlua.ml

@@ -823,6 +823,7 @@ and gen_expr ?(local=true) ctx e = begin
 		b();
                 println ctx "return _hx_pcall_default";
                 println ctx "end)";
+                ctx.in_loop_try <- old_in_loop_try;
                 println ctx "if not _hx_status and _hx_result == \"_hx_pcall_break\" then";
                 if ctx.in_loop then
                     if old_in_loop_try then
@@ -888,7 +889,6 @@ and gen_expr ?(local=true) ctx e = begin
                 println ctx "elseif _hx_result ~= _hx_pcall_default then";
                 println ctx "  return _hx_result";
                 print ctx "end";
-                ctx.in_loop_try <- old_in_loop_try;
 	| TSwitch (e,cases,def) ->
 		List.iteri (fun cnt (el,e2) ->
 		    if cnt == 0 then spr ctx "if "

+ 18 - 0
tests/unit/src/unit/issues/Issue6349.hx

@@ -0,0 +1,18 @@
+package unit.issues;
+class Issue6349 extends Test{
+	function test() {
+		var a = [];
+		for (i in 1...5) {
+			try {
+				if (i== 1) {
+					throw null;
+				}
+				a.push(i);
+			}
+			catch (_:Dynamic) {
+				continue;
+			}
+		}
+		eq(a + '', '[2,3,4]');
+	}
+}