Skip to content

Commit

Permalink
[eval] fix Array.resize retaining values
Browse files Browse the repository at this point in the history
closes #11317
  • Loading branch information
Simn committed Sep 25, 2023
1 parent c0d033d commit 71c41a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/macro/eval/evalArray.ml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,6 @@ let resize a l =
set a (l - 1) vnull;
()
end else if a.alength > l then begin
ignore(splice a l (a.alength - l) a.alength);
()
Array.fill a.avalues l (a.alength - l) vnull;
a.alength <- l;
end else ()
10 changes: 10 additions & 0 deletions tests/unit/src/unit/issues/Issue11317.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package unit.issues;

class Issue11317 extends Test {
function test() {
var array:Array<String> = ["0", "1", "2", "3", "4"];
array.resize(0);
array.resize(5);
utest.Assert.same([null, null, null, null, null], array);
}
}

0 comments on commit 71c41a0

Please sign in to comment.