diff --git a/analyze_structure.lua b/analyze_structure.lua index 65cc1cb..b434c65 100644 --- a/analyze_structure.lua +++ b/analyze_structure.lua @@ -209,13 +209,17 @@ local function has_uniform_structure (t) -- Find the key and value types. local first_key = next(t) if first_key == nil then return true end - local key_type, value_type = type(first_key), type(t[first_key]) + local key_type, value_type = type(first_key), type(t[first_key]) + local nr_elems = (value_type == 'table') and nr_elements_in_table(t[first_key]) or nil -- Ensure every other key value pair is the same. for key, value in pairs(t) do if type(key) ~= key_type or type(value) ~= value_type then return false end + if nr_elems and nr_elems ~= nr_elements_in_table(value) then + return false + end end return true