Skip to content

Compiler loop on tuple inference #24158

Closed as duplicate of#19730
Closed as duplicate of#19730
@dvmason

Description

@dvmason

Zig Version

0.15.0-dev.736+b6d904624

Steps to Reproduce and Observed Behavior

Save the following as bug24158.zig and run zig test bug24158.zig

const std = @import("std");
const lastPredefinedSymbol = 53;
const staticSymbols =  blk: {
    var symbolArray = [_]PointedObject{undefined} ** lastPredefinedSymbol;
    for (symbolArray[0..]) |*sym|
         initSymbol(sym);
    break :blk symbolArray;
};
fn initSymbol(sym: *PointedObject) void {
    sym.header = .{
//    sym.header = HeapHeader{
        .classIndex = .Symbol, .hash = 42, .format = .notIndexable, .age = .static, .length = 1 };
}
test "make it run" {
    std.debug.print("in test {}\n", .{&staticSymbols[0]});
}
const PointedObject = packed struct {
    header: HeapHeader,
    data: packed union {
        int: i64,
        unsigned: u64,
    },
};
const HeapHeader = packed struct(u64) {
    classIndex: ClassIndex = .none,
    hash: u24 = 0,
    format: Format = .free,
    immutable: bool = false,
    age: Age = .nursery,
    length: u11 = 0,
    forwarded: bool = false,
};
const Age = enum(u4) {
    nursery,
    static,
};
const Format = enum(u7) {
    notIndexable, // this is an Object with no indexable values
    free,
};
const ClassIndex = enum(u16) {
    none = 0,
    Symbol,
};

Compiler goes into an infinite loop. (also happened at least in some 0.14 versions). This is on aarch64/macos

Expected Behavior

Compiler to find errors or get on with the test.

Replacing the tuple with the struct name resolves the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions