diff --git a/library/LuaTypes.cpp b/library/LuaTypes.cpp index 4507cb718..ac99600a1 100644 --- a/library/LuaTypes.cpp +++ b/library/LuaTypes.cpp @@ -1403,7 +1403,6 @@ static void PushFieldInfoSubTable(lua_State *state, const struct_field_info *fie Lua::TableInsert(state, "original_name", field->extra->original_name); } } - // freeze_table(state); // TODO: make pairs() work } /** diff --git a/test/structures/struct_fields.lua b/test/structures/struct_fields.lua index f9b3c41fc..53c9ebcc1 100644 --- a/test/structures/struct_fields.lua +++ b/test/structures/struct_fields.lua @@ -43,6 +43,13 @@ end function test.nonexistent() expect.nil_(df.coord._fields.nonexistent) + + expect.error_match('string expected', function() + expect.nil_(df.coord._fields[2]) + end) + expect.error_match('string expected', function() + expect.nil_(df.coord._fields[nil]) + end) end function test.readonly() @@ -52,13 +59,11 @@ function test.readonly() expect.error_match(READONLY_MSG, function() df.coord._fields.nonexistent = 'foo' end) - -- see TODOs in LuaTypes.cpp - -- expect.error_match(READONLY_MSG, function() - -- df.coord._fields.x.name = 'foo' - -- end) + expect.nil_(df.coord._fields.nonexistent) + -- should have no effect + df.coord._fields.x.name = 'foo' expect.eq(df.coord._fields.x.name, 'x') - expect.nil_(df.coord._fields.nonexistent) end function test.circular_refs_init()