zig icon indicating copy to clipboard operation
zig copied to clipboard

Allow coercing ref to anonymous array init to [*c]

Open Pyrolistical opened this issue 1 year ago • 0 comments

Zig Version

0.13.0-dev.73+db890dbae

Steps to Reproduce and Observed Behavior

Missing case for https://github.com/ziglang/zig/issues/18924

const std = @import("std");
const expectEqual = std.testing.expectEqual;

test "ref to anon array init coerced to many-c-ptr" {
    const values: [*c]const i32 = &.{ 5, -6 };
    try expectEqual(5, values[0]);
    try expectEqual(-6, values[1]);
}

Fails to compile:

error: type 'i32' does not support array initialization syntax
    const values: [*c]const i32 = &.{ 5, -6 };

Expected Behavior

Expected test to pass

Pyrolistical avatar May 07 '24 08:05 Pyrolistical