Skip to content

Commit

Permalink
[LUA] Fix do while loops on lua (#11807)
Browse files Browse the repository at this point in the history
* Fix do while loops on lua

* Add tests for issue 11807

* Change the pass condition for unit/issues/11807
  • Loading branch information
NeeEoo authored Dec 16, 2024
1 parent 5e9ea0b commit 52d1bdd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/generators/genlua.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/src/unit/issues/Issue11807.hx
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 52d1bdd

Please sign in to comment.