Allow some cases of error union with error set payload #14698
Labels
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
I believe #12462 is what made it so that this no longer works:
And while I can agree with that case, this also no longer works:
But I believe that at least this case is something that should be allowed.
Interestingly, this does work (note that the only difference is that the
CodegenFail
is "optional"):But removing the two question marks:
I use this
fail
function to emit compile errors and it thus always returns an error which indicates that codegen failed so you can return with the result offail
and have it propagate correctly.However,
fail
ing itself can also fail: it might run out of memory (in my case I'm allocating an error message).Here's an example of its usage:
I think this communicates intent quite clearly: we want to fail so we
try
to fail and then if that succeeded we return with an error from the function and make it propagate.But now I have to change it to
return func.fail("", .{})
(notry
) which I think doesn't communicate intent as well as before. Failing itself might fail so it might returnerror.OutOfMemory
which has nothing to do with the normally only expected result offail
oferror.CodegenFail
.Also, I would like to keep
error.OutOfMemory
inferred.The text was updated successfully, but these errors were encountered: