Skip to content

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

@Pyrolistical

Description

@Pyrolistical

Zig Version

0.13.0-dev.73+db890dbae

Steps to Reproduce and Observed Behavior

Missing case for #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

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions