Browse Source

[LUA] Fix do while loops on lua (#11807)

* Fix do while loops on lua

* Add tests for issue 11807

* Change the pass condition for unit/issues/11807
Ne_Eo 8 months ago
parent
commit
52d1bdd701
2 changed files with 15 additions and 2 deletions
  1. 2 2
      src/generators/genlua.ml
  2. 13 0
      tests/unit/src/unit/issues/Issue11807.hx

+ 2 - 2
src/generators/genlua.ml

@@ -585,9 +585,9 @@ and gen_loop ctx cond do_while e =
         println ctx "local _hx_do_first_%i = true;" ctx.break_depth;
     let b = open_block ctx in
     print ctx "while ";
-    gen_cond ctx cond;
     if do_while then
-        print ctx " or _hx_do_first_%i" ctx.break_depth;
+        print ctx "_hx_do_first_%i or " ctx.break_depth;
+    gen_cond ctx cond;
     print ctx " do ";
     if do_while then begin
         newline ctx;

+ 13 - 0
tests/unit/src/unit/issues/Issue11807.hx

@@ -0,0 +1,13 @@
+package unit.issues;
+
+class Issue11807 extends Test {
+	function test() {
+		var test = null;
+
+		do {
+			test = {type: 5};
+		} while (test.type != 5);
+
+		eq(5, test.type);
+	}
+}