local M = {} ---@param protected (fun(): table) | table function M.protect(protected) ---@type table local tbl if type(protected) == "table" then tbl = protected elseif type(protected) == "function" then tbl = protected() else error("expected a table or a function that returns a table, got " .. type(protected), 2) end return setmetatable({}, { __index = tbl, __newindex = function(_, k, v) error("attempted to change constant " .. tostring(k) .. " to " .. tostring(v), 2) end, }) end return M