THRIFT-5325: Fix Lua library writeStructEnd() in TCompactProtocol
Client: lua
Patch: Jeffrey Han

This closes #2297
diff --git a/lib/lua/TCompactProtocol.lua b/lib/lua/TCompactProtocol.lua
index 0ebccac..8ec7b3a 100644
--- a/lib/lua/TCompactProtocol.lua
+++ b/lib/lua/TCompactProtocol.lua
@@ -124,8 +124,8 @@
 end
 
 function TCompactProtocol:writeStructEnd()
-  self.lastFieldId = self.lastField[self.lastFieldIndex]
   self.lastFieldIndex = self.lastFieldIndex - 1
+  self.lastFieldId = self.lastField[self.lastFieldIndex]
 end
 
 function TCompactProtocol:writeFieldBegin(name, ttype, id)