Recursively iterating over table crashes the script engine

Issue #28 wontfix
Fabian Maurer created an issue

This code crashes the scriptengine, probably a stackoverflow since it always tries to print _G.

function PrintTable2(tab, indent)
    if(indent == nil) then
        indent = "";
    end

    for k,v in next, tab do 
        type = typeof(v);
        print "$indent $k $v ($type)";
        if(type == "table") then
            PrintTable2(v, "    $indent");
        end
    end
end
PrintTable2(_G);

Comments (1)

  1. Chimaine

    This happens when a table contains itself, as _G does. For pretty printing of tables, use the Table.Dump function. It takes care of that.

  2. Log in to comment