aboutsummaryrefslogtreecommitdiff
path: root/test/cases/comptime_aggregate_print.zig
blob: f0399b3fcbe30288489e82444a681ebbd3f2cadd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const UnionContainer = union {
    buf: [2]i32,
};

fn getUnionSlice() []i32 {
    var c = UnionContainer{ .buf = .{ 1, 2 } };
    return c.buf[0..2];
}

const StructContainer = struct {
    buf: [2]i32,
};

fn getStructSlice() []i32 {
    var c = StructContainer{ .buf = .{ 3, 4 } };
    return c.buf[0..2];
}

comptime {
    @compileLog(getUnionSlice());
    @compileLog(getStructSlice());
}

pub fn main() !void {}

// TODO: the output here has been regressed by #19414.
// Restoring useful output here will require providing a Sema to TypedValue.print.

// error
//
// :20:5: error: found compile log statement
//
// Compile Log Output:
// @as([]i32, @as([*]i32, @ptrCast(&@as(tmp.UnionContainer, .{ .buf = .{ 1, 2 } }).buf))[0..2])
// @as([]i32, @as([*]i32, @ptrCast(&@as(tmp.StructContainer, .{ .buf = .{ 3, 4 } }).buf))[0..2])