This commit is contained in:
Zynh Ludwig 2024-12-02 14:05:55 -08:00
parent 375246159d
commit 87f018ceea

View file

@ -98,6 +98,7 @@ local function is_safe(report)
return unsafe, unsafe_idx_1, unsafe_idx_2 return unsafe, unsafe_idx_1, unsafe_idx_2
end end
-- Copy the report, remove the specified index, and test if it is safe
local function test_altered_report(report, idx) local function test_altered_report(report, idx)
local test_report = table.shallow_copy(report) local test_report = table.shallow_copy(report)
table.remove(test_report, idx) table.remove(test_report, idx)
@ -107,9 +108,11 @@ end
local safe_count = 0 local safe_count = 0
for _, report in ipairs(reports) do for _, report in ipairs(reports) do
-- if unsafe == true, idx1 and idx2 will be null
local unsafe, idx1, idx2 = is_safe(report) local unsafe, idx1, idx2 = is_safe(report)
if unsafe then if unsafe then
-- if the report is unsafe, generate 2 reports with the potentially bad values removed, and test them again
if not test_altered_report(report, idx1) or not test_altered_report(report, idx2) then if not test_altered_report(report, idx1) or not test_altered_report(report, idx2) then
unsafe = false unsafe = false
end end