So I am making a python formatter, a recursive one. I noticed at one point im duplicating effort for some stuff
.parameters, .argument_list, .tuple => {
try self.output.append(allocator, '(');
const child_count = node.namedChildCount();
var i: u32 = 0;
while (i < child_count) : (i += 1) {
const child = node.namedChild(i).?;
var child_cursor = child.walk();
try self.formatNode(allocator, &child_cursor, 0);
if (i + 1 < child_count) {
try self.output.appendSlice(allocator, ", ");
}
}
try self.output.append(allocator, ')');
},
these were all the same for (), however i have some other similar stuff for lists which use {}, i thought to condense the splatting of the children with
fn splatChildren(self: *Fmt, allocator: std.mem.Allocator, node: ts.Node) !void {
const child_count = node.namedChildCount();
var i: u32 = 0;
while (i < child_count) : (i += 1) {
const elem = node.namedChild(i).?;
var elem_cursor = elem.walk();
try self.formatNode(allocator, &elem_cursor, 0);
if (i + 1 < child_count) {
try self.output.appendSlice(allocator, ", ");
}
}
}```
however switching to the splat method cause the cannot infer error set, specifically at
```bash
run
└─ run exe pyzfmt
└─ compile exe pyzfmt Debug native 1 errors
src/fmt.zig:458:32: error: unable to resolve inferred error set
try self.formatNode(allocator, &elem_cursor, 0);
(formatNode is the recursive function)