Ver código fonte

[lua] fix anonymous object printing issue with null fields on tables

Justin Donaldson 4 anos atrás
pai
commit
141e037e53
1 arquivos alterados com 8 adições e 3 exclusões
  1. 8 3
      std/lua/_lua/_hx_tostring.lua

+ 8 - 3
std/lua/_lua/_hx_tostring.lua

@@ -82,11 +82,16 @@ function _hx_tostring(obj, depth)
             return _hx_print_class(obj, depth)
         else
             local buffer = {}
-            for k,v in pairs(obj) do
+            local ref = obj
+            if obj.__fields__ ~= nil then
+                ref = obj.__fields__
+            end
+            for k,v in pairs(ref) do
                 if _hx_hidden[k] == nil then
                     _G.table.insert(buffer, _hx_tostring(k, depth+1) .. ' : ' .. _hx_tostring(obj[k], depth+1))
                 end
             end
+
             return "{ " .. table.concat(buffer, ", ") .. " }"
         end
     else
@@ -97,9 +102,9 @@ end
 
 function _hx_error(obj)
     if obj.value then
-        _G.print("Runtime Error: " .. _hx_tostring(obj.value));
+        _G.print("runtime error:\n " .. _hx_tostring(obj.value));
     else
-        _G.print("Runtime Error: " .. tostring(obj));
+        _G.print("runtime error:\n " .. tostring(obj));
     end
 
     if _G.debug and _G.debug.traceback then