Skip to content

--optimize can produce non-compiling code when simplifying statements #2

@9382

Description

@9382

--optimize can cause non-compiling code, for example in the case of:

local function hi()
	if true then
		return 1
	end
	return 2
end
print(hi())

the if true then's block gets inlined. However, this causes a statement block with 2 return statements, which will never compile. Ideally, if a block collapses due to being always true and the block ends with a return or similar (break, continue, I think that's it), everything after it should not be written, though I'm not immediately sure how such a thing would be implemented. Alternatively, the if then end could be replaced with a do end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions