zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit ebca8c2dbba5b4c0db9910d4cbd854d679114a8d (tree)
parent 54b3484256695381c034aa30f322b1499a4b27c8
Author: Kendall Condon <goon.pri.low@gmail.com>
Date:   Mon, 23 Mar 2026 18:47:56 -0400

x86_64: fix runtime array concat with comptime slice

Diffstat:
Msrc/codegen/x86_64/CodeGen.zig | 1+
Mtest/behavior/array.zig | 12++++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/codegen/x86_64/CodeGen.zig b/src/codegen/x86_64/CodeGen.zig @@ -170801,6 +170801,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { else => |e| return e, }; try ops[0].toSlicePtr(cg); + try ops[1].toSlicePtr(cg); cg.select(&.{}, &.{}, &ops, switch (air_tag) { else => unreachable, inline .memcpy, .memmove => |symbol| comptime &.{.{ diff --git a/test/behavior/array.zig b/test/behavior/array.zig @@ -45,6 +45,18 @@ fn getArrayLen(a: []const u32) usize { return a.len; } +test "runtime array concat with comptime slice" { + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; + + var a: [1]u8 = .{1}; + const b = (comptime @as([]const u8, &.{0})) ++ &a; + const c = &a ++ (comptime @as([]const u8, &.{0})); + try std.testing.expectEqualSlices(u8, &.{ 0, 1 }, b); + try std.testing.expectEqualSlices(u8, &.{ 1, 0 }, c); +} + test "array concat with undefined" { if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;