Skip to content

Indexing on string fails when index is an expression with side effects #867

@voces

Description

@voces

Indexing on strings (e.g., myString[7]) duplicates the passed index expression, which results in incorrect code when the index expression has side effects, such as incrementing a value (myString[i++]).

Example, which would produce the string "01" instead of the expected "0":
https://typescripttolua.github.io/play/#code/FAGwpgLgBAllC8UAMBuUkoGcICcFQCIkBGAJgLWGxwG0YBqegXTSA

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