Skip to content

allow chained multi-pointer slicing to omit end value when last one does not #14611

@nektro

Description

@nektro

Zig Version

0.11.0-dev.1584+9ccd8ed0a

Steps to Reproduce and Observed Behavior

const std = @import("std");

test {
    const a = [_]u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    const b = &a;
    const c: [*]const u8 = b;
    foo(c[2..][0..3]);
}

fn foo(x: []const u8) !void {
    try std.testing.expectEqualSlices(u8, &.{ 2, 3, 4 }, x);
}
test.zig:7:10: error: slice of pointer must include end value
    foo(c[2..][0..3]);
        ~^~~~~

Expected Behavior

all tests passed

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions