-- A syntax error stops the whole file, so
-- the code is compiled apart by load
-- = assigns, == compares
local chunk1, err1 = load("if x = 0 then end")
-- chunk1 = nil
-- err1 = [string "if x = 0 then end"]:1:
-- 'then' expected near '='
-- A missing then is caught the same way
local chunk2, err2 = load("if x == 0 end")
-- err2 = [string "if x == 0 end"]:1:
-- 'then' expected near 'end'
-- The correct form compiles
local chunk3 = load("if x == 0 then end")
-- type(chunk3) = function
print("chunk1 = " .. tostring(chunk1))
print("err1 = " .. err1)
print("err2 = " .. err2)
print("type(chunk3) = " .. type(chunk3))