revert: remove safeToString_ and recursive toString handling due to memory leak on runtime errors
The safeToString_ mechanism introduced in 40897f33 used per-fiber maps and lists to detect recursive toString calls, but leaked memory when runtime errors occurred before cleanup. This reverts to direct toString implementations for List and Map, removing the recursive detection logic and updating tests to mark self-referencing containers as TODO.
This commit is contained in:
@@ -24,28 +24,4 @@ IO.print(s == "{1: 2, 3: 4, 5: 6}" ||
|
||||
s == "{5: 6, 1: 2, 3: 4}" ||
|
||||
s == "{5: 6, 3: 4, 1: 2}") // expect: true
|
||||
|
||||
// Map that directly contains itself.
|
||||
var map = {}
|
||||
map["key"] = map
|
||||
IO.print(map) // expect: {key: ...}
|
||||
|
||||
// Map that indirectly contains itself.
|
||||
map = {}
|
||||
map["a"] = {"b": {"c": map}}
|
||||
|
||||
IO.print(map) // expect: {a: {b: {c: ...}}}
|
||||
|
||||
// Map containing an object that calls toString on a recursive map.
|
||||
class Box {
|
||||
new(field) { _field = field }
|
||||
toString { "box " + _field.toString }
|
||||
}
|
||||
|
||||
map = {}
|
||||
map["box"] = new Box(map)
|
||||
IO.print(map) // expect: {box: box ...}
|
||||
|
||||
// Map containing a list containing the map.
|
||||
map = {}
|
||||
map["list"] = [1, map, 2]
|
||||
IO.print(map) // expect: {list: [1, ..., 2]}
|
||||
// TODO: Handle maps that contain themselves.
|
||||
Reference in New Issue
Block a user