Skip to content

std.meta.Tuple can't handle slice of type array #15822

@iacore

Description

@iacore

Zig Version

0.11.0-dev.3268+9d4d96ca9

Steps to Reproduce and Observed Behavior

Run zig test on the following file

const std = @import("std");

const Arr: [3]type = .{ i32, i32, i32 };
const T: type = std.meta.Tuple(Arr[0..2]);

test "simple test" {
    var foo: T = .{ 0, 0 };
    _ = foo;
}

Output:

❯ zig build test
zig test Debug native: error: the following command failed with 1 compilation errors:
/home/user/.local/share/zig/0.11.0-dev.3268+9d4d96ca9/files/zig test /home/user/computing/debug/zig-meta-tuple/src/main.zig --cache-dir /home/user/computing/debug/zig-meta-tuple/zig-cache --global-cache-dir /home/user/.cache/zig --name test --listen=- 
Build Summary: 0/3 steps succeeded; 1 failed (disable with -fno-summary)
test transitive failure
└─ run test transitive failure
   └─ zig test Debug native 1 errors
/home/user/.local/share/zig/0.11.0-dev.3268+9d4d96ca9/files/lib/std/meta.zig:1060:60: error: comptime dereference requires '[2]type' to have a well-defined layout, but it does not.
    return CreateUniqueTuple(types.len, types[0..types.len].*);
                                        ~~~~~~~~~~~~~~~~~~~^~
src/main.zig:4:31: note: called from here
const T: type = std.meta.Tuple(Arr[0..2]);
                ~~~~~~~~~~~~~~^~~~~~~~~~~

Expected Behavior

Test should pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions