mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Auto strict mode based on optimization level
This commit is contained in:
parent
8b4210e66a
commit
cc4b390d3d
5 changed files with 31 additions and 28 deletions
|
|
@ -91,28 +91,22 @@ local vide = {
|
|||
end
|
||||
}
|
||||
|
||||
do
|
||||
local set = false
|
||||
|
||||
setmetatable(vide :: any, {
|
||||
__index = function(_, index: unknown): ()
|
||||
if index == "strict" then
|
||||
return flags.strict
|
||||
else
|
||||
throw(`{tostring(index)} is not a valid member of vide`)
|
||||
end
|
||||
end,
|
||||
|
||||
__newindex = function(_, index: unknown, value: unknown)
|
||||
if index == "strict" then
|
||||
if set then throw "strict mode has already been set" end
|
||||
set = true
|
||||
flags.strict = value :: boolean
|
||||
else
|
||||
throw(`{tostring(index)} is not a valid member of vide`)
|
||||
end
|
||||
setmetatable(vide :: any, {
|
||||
__index = function(_, index: unknown): ()
|
||||
if index == "strict" then
|
||||
return flags.strict
|
||||
else
|
||||
throw(`{tostring(index)} is not a valid member of vide`)
|
||||
end
|
||||
})
|
||||
end
|
||||
end,
|
||||
|
||||
__newindex = function(_, index: unknown, value: unknown)
|
||||
if index == "strict" then
|
||||
flags.strict = value :: boolean
|
||||
else
|
||||
throw(`{tostring(index)} is not a valid member of vide`)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
return vide
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue