Commit 1b432072b5

dweiller <4678790+dweiller@users.noreplay.github.com>
2023-03-10 03:03:40
std.Build: detect and disallow top-level step name clashes
1 parent 339cae7
Changed files (1)
lib
lib/std/Build.zig
@@ -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;
 }