Skip to content

Post-incrementing properties generates invalid identifiers #276

Description

@velcroz

Post-incrementing properties or array values generates invalid lua identifiers

class Test {
	lastId = 0;

	constructor() {
		log(this.lastId++);
	}
}

The generated code looks like this

log((function()
        local __originalValueself.lastId0 = self.lastId;
        self.lastId = (self.lastId+1);
        return __originalValueself.lastId0;
 end

A similar situation happens when trying to access a variable using bracket notation

let data = {value : 0};
log(data['value']++);

Generated code:

local data = {value = 0};
log((function()
    local __originalValuedata["value"]0 = data["value"];
    data["value"] = (data["value"]+1);
    return __originalValuedata["value"]0
end
)());

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