Static_string_map.zig:122:32: error: expected type 'u32', found 'usize'

pub fn new(err: Errors, span: Span, meta: anytype) NeoError {
    const meta_info = @typeInfo(@TypeOf(meta)).Struct;
    const fields = meta_info.fields;

    var slice = allocator.alloc([2][]const u8, fields.len) catch unreachable;

    comptime var i = 0;
    inline for (fields) |field| {
        slice[i] = .{ field.name, @field(meta, field.name) };

        i += 1;
    }

    const _meta = std.StaticStringMap([]const u8).init(slice, allocator);

    return NeoError{ .err = err, .span = span, .meta = _meta };
}

i already tested slice, returning all correctly:
{ { character, ~ } }

Where is the issue?

This was fixed shortly after 0.13.0 was released:

2 Likes

I’ve already seen this, but i can’t imagine how to use that in alloc

You can:

  • either use the latest 0.14.0-dev
  • or patch the zig library sources to fix the problem.
    Patching the library is really easy (the sources are already included with the zig binary) from your zig installation directory cd lib/std, edit static_string_map.zig and change line 122 to:
      .len = @intCast(kvs_list.len),
    
    After patching simply build your program (zig detects that the sources of its library are changed and rebuilds the library from the sources).
1 Like