28 lines
585 B
Plaintext
28 lines
585 B
Plaintext
--!strict
|
|
|
|
--[[
|
|
Restricts the reading of missing members for a table.
|
|
]]
|
|
|
|
local logError = require "../Logging/logError"
|
|
|
|
type table = { [any]: any }
|
|
|
|
local function restrictRead(tableName: string, strictTable: table): table
|
|
-- FIXME: Typed Luau doesn't recognise this correctly yet
|
|
local metatable = getmetatable(strictTable :: any)
|
|
|
|
if metatable == nil then
|
|
metatable = {}
|
|
setmetatable(strictTable, metatable)
|
|
end
|
|
|
|
function metatable:__index(memberName)
|
|
logError("strictReadError", nil, tostring(memberName), tableName)
|
|
end
|
|
|
|
return strictTable
|
|
end
|
|
|
|
return restrictRead
|