X Tutup
Skip to content

Enums as array index #687

@cipherxof

Description

@cipherxof

In 0.23.0 the following code seemed to work properly.

let swapItm = equipment.item[itm.slot];

It would compile to:

local swapItm = equipment.item[itm.slot + 1]

After updating to 0.24.0 or higher I noticed all my code using enums for array indicies stopped working. I realized the code was now compiling to the following:

local swapItm = equipment.item[itm.slot]

Another interesting thing to note in 0.24.0+ is that the +1 gets added in some situations.

let swapItm = equipment.item[itm.slot + 0];

compiles to

local swapItm = equipment.item[(itm.slot + 0) + 1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup