Remix.run Logo
Error payloads in Zig(srcreigh.ca)
47 points by srcreigh 4 hours ago | 5 comments
scuff3d an hour ago | parent | next [-]

Continues to be a point of annoyance that Zig doesn't properly support payloads in errors.

smlavine an hour ago | parent | next [-]

I thought so too at first, coming from a language (Hare) where they are very easy and common, but the Diagnostics pattern isn't that bad once you expect it. Various examples: https://ziggit.dev/search?q=Diagnostics

srcreigh 3 minutes ago | parent [-]

IIUC hare doesn’t have inferred error union return types, or errdefer, so payloads are just returning a tagged union.

I don’t personally see how zig the language could make error payloads better than what’s in my post. Maybe they could add automatic inference for the return type? Idk how that would work.

loeg 23 minutes ago | parent | prev [-]

Right. It's one thing to build the equivalent of Result into the language -- great. It's another to make it only support simple enum variants and not be extensible.

deepriverfish an hour ago | parent | prev [-]

page is dead