Skip to content

Commit

Permalink
Merge pull request #16 from Srekel/srekel-unused-args-fix
Browse files Browse the repository at this point in the history
Srekel unnamed args fix
  • Loading branch information
lassade authored Dec 13, 2023
2 parents f4f237e + 4a791ea commit 6a9c6b3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Transpiler.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,10 @@ fn visitFunctionTemplateDecl(self: *Self, node: *const json.Value) !void {
var body = std.ArrayList(u8).init(self.allocator);
defer body.deinit();

for (f_items) |*f_item| {
var unused_arg_names = try std.ArrayList(u8).initCapacity(self.allocator, 16);
defer unused_arg_names.deinit();

for (f_items, 0..) |*f_item, i_item| {
const arg_kind = f_item.object.get("kind").?.string;
if (mem.eql(u8, arg_kind, "ParmVarDecl")) {
// todo: obsolete
Expand All @@ -1435,7 +1438,16 @@ fn visitFunctionTemplateDecl(self: *Self, node: *const json.Value) !void {
}
comma = true;

const arg_name = f_item.object.get("name").?.string;
const arg_name_opt = f_item.object.get("name");
const arg_name = blk: {
if (arg_name_opt) |an|
break :blk an.string
else {
unused_arg_names.resize(0) catch unreachable;
try unused_arg_names.writer().print("arg_{}", .{i_item});
break :blk unused_arg_names.items;
}
};
const arg_type = try self.transpileType(qual);
defer self.allocator.free(arg_type);

Expand Down

0 comments on commit 6a9c6b3

Please sign in to comment.