setPort from `std.Io.net.IpAddress` not working?

Hello,

I was trying to do an udp server / client with the new Io implementation and wanted to change the port on an IpAddress. But I get an error and now wanted to just know if I am doing something wrong or is this a Zig issue?
I tried to find any issue on github/codeberg regarding this but I didn’t find anything

Here is an example code where I get this error:

const std = @import(“std”);

pub fn main() !void {
	var address: std.Io.net.IpAddress = try .parse("127.0.0.1",0);
	address.setPort(8080);
}

And the error I get is:

master/lib/std/Io/net.zig:156:9: error: else prong required when switching on type '*Io.net.IpAddress'
        switch (a) {
        ^~~~~~
referenced by:
    main: src/main.zig:5:2

I get the same error, so I believe this is a Zig error. I didn’t find anything on the issue tracker for Github or Codeberg. It would be good to file an issue. I’m not sure that code gets used frequently and due to lazy compilation, they compiler team may not have hit this yet.

Oddly, address.getPort() doesn’t have the same issue, at least not from my testing.

I now created an issue

2 Likes