Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Llama.List.set relative to list end position #24

Open
tapiov opened this issue Dec 6, 2021 · 2 comments
Open

Llama.List.set relative to list end position #24

tapiov opened this issue Dec 6, 2021 · 2 comments

Comments

@tapiov
Copy link

tapiov commented Dec 6, 2021

Probably something I am doing wrong here but see the last two cases

local l = List.create(5,"foo")

print(l) 

-- Result OK
                    [1] = "foo",
                    [2] = "foo",
                    [3] = "foo",
                    [4] = "foo",
                    [5] = "foo"

print(List.set(l, 1, "foz"))

-- OK
                   [1] = "foz",
                   [2] = "foo",
                   [3] = "foo",
                   [4] = "foo",
                   [5] = "foo"


print(List.set(l, -1, "bar"))

-- OK
                    [1] = "foo",
                    [2] = "foo",
                    [3] = "foo",
                    [4] = "bar",
                    [5] = "foo"

-- Should error? Or add value at index 6?
print(List.set(l, 6, "baz"))

                    [1] = "foo",
                    [2] = "foo",
                    [3] = "foo",
                    [4] = "foo",
                    [5] = "foo"

-- Should set last value to "baz", but errors
print(List.set(l, 0, "baz"))

--[[
  12:24:03.853  ReplicatedStorage.Common.Llama.List.set:17: index 0 out of bounds of list of length 5  -  Server - set:17
  12:24:03.854  Stack Begin  -  Studio
  12:24:03.854  Script 'ReplicatedStorage.Common.Llama.List.set', Line 17 - function set  -  Studio - set:17
  12:24:03.854  Script 'ServerScriptService.Server', Line 49  -  Studio - Server:49
  12:24:03.854  Stack End  -  Studio
]]

Full code

local l = List.create(5,"foo")

print(l)

print(List.set(l, 1, "foz"))

print(List.set(l, -1, "bar"))

print(List.set(l, 6, "baz"))

print(List.set(l, 0, "baz"))
@freddylist
Copy link
Owner

The last one is definitely a bug. The second to last one should error. It's an easy fix but I don't know if it was a good idea to support negative indices in the first place...

That said, I'll fix (or remove) this feature in the next major release of Llama 👍

Thanks for the bug report!

@tapiov
Copy link
Author

tapiov commented Dec 6, 2021

Ok, thanks. Llama is definetely something that's very useful for me. I'll let you know if I find more issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants