Skip to content

Bug when destructuring a result directly. #995

@yancouto

Description

@yancouto

I reproduce this bug using string.find, but maybe it applies to all @tupleReturn?

The following code reproduces this error on the tstl playground:

// works as it should
const result = string.find("a", "b");
const [c, ...d] = result;

// Doesn't work
const [a, ...b] = string.find("a", "b");

Gets translated to

result = {
    string.find("a", "b")
}
c = result[1]
d = __TS__ArraySlice(result, 1)
local ____ = string.find("a", "b")
a = ____[1]
b = __TS__ArraySlice(____, 1)

On the second case, it uses string.find result directly without putting it into a table, which causes a nil error.

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