std.Build: detect and disallow top-level step name clashes

This commit is contained in:
dweiller 2023-03-10 13:03:40 +11:00 committed by Andrew Kelley
parent 339cae7fd0
commit 1b432072b5

View File

@ -926,7 +926,12 @@ pub fn step(self: *Build, name: []const u8, description: []const u8) *Step {
}),
.description = self.dupe(description),
};
self.top_level_steps.put(self.allocator, step_info.step.name, step_info) catch @panic("OOM");
const gop = self.top_level_steps.getOrPut(self.allocator, name) catch @panic("OOM");
if (gop.found_existing) std.debug.panic("A top-level step with name \"{s}\" already exists", .{name});
gop.key_ptr.* = step_info.step.name;
gop.value_ptr.* = step_info;
return &step_info.step;
}