--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
--optimizecan cause non-compiling code, for example in the case of: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 areturnor 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, theif then endcould be replaced with ado end