Skip to content

Commit

Permalink
Fixed: LIST() did not encapsulate non-list values properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
MTrop committed Jan 9, 2022
1 parent c905885 commit a48ec98
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ RookScript (C) Black Rook Software
by Matt Tropiano et al. (see AUTHORS.txt)


Changed in 1.14.1
-----------------

- `Fixed` Host function `LIST()` did not encapsulate non-list values properly.


Changed in 1.14.0
-----------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public boolean execute(ScriptInstance scriptInstance, ScriptValue returnValue)
scriptInstance.popStackValue(value);
if (value.isList())
{
returnValue.setEmptyList(value.length());
returnValue.setEmptyList(value.length(), value.length());
for (int i = 0; i < value.length(); i++)
{
value.listGetByIndex(i, temp);
Expand All @@ -66,7 +66,7 @@ public boolean execute(ScriptInstance scriptInstance, ScriptValue returnValue)
}
else
{
returnValue.setEmptyList(4);
returnValue.setEmptyList(1, 4);
returnValue.listSetByIndex(0, value);
}
return true;
Expand Down
9 changes: 9 additions & 0 deletions src/test/resources/scripts/test7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

entry main()
{
x = [1,2];
println(list(1));
println(list(x));
println(list(x) === x); // should be false
println(listnew(1));
}

0 comments on commit a48ec98

Please sign in to comment.