#Is this normal behavior in zig compiler ?

1 messages · Page 1 of 1 (latest)

manic perch
#

Union:

pub const Value = union(enum) {
    string: []const u8,
    int: i64,
    list: []Value,
}

Type ParseResult:

const ParseResult = struct { value: Value, new_cursor: usize };

Compiler error for list case :
app/bencoded.zig:37:28: error: expected type 'bencoded.Value', found '[]bencoded.Value'
return .{ .value = list, .new_cursor = index };
^~~~

upper hill
#

you have to explicitly initialize a union, you cant just pass a value

#

you probably want .value = .{ .list = list }

manic perch
#

I totally forgot about that even though i ve had it done like that for a lot of other parser methods