You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disclaimer: This is kind-of a proposal and kind-of a bug, so I'm not sure how this should be labelled.
The Problem
Presently, attempting to return a struct from a fallible function using an anonymous struct literal will fail, with the error: type 'ErrorSet!StructType' does not support struct initialization syntax. I believe this to be a deficiency in the current implementation of Zig, especially if #5038 were to be accepted and implemented. The current behaviour is an unnecessary implementation as far as I can tell, and makes code more verbose than necessary or desirable.
The Solution
There are two possible solutions here. Firstly, to simply allow this coercion to be made. I don't see any fundamental contradictions here which would prevent this from working. Alternatively, #7812 would also address this, as returning values would be separated from throwing errors.
Disclaimer: This is kind-of a proposal and kind-of a bug, so I'm not sure how this should be labelled.
The Problem
Presently, attempting to return a struct from a fallible function using an anonymous struct literal will fail, with the error:
type 'ErrorSet!StructType' does not support struct initialization syntax
. I believe this to be a deficiency in the current implementation of Zig, especially if #5038 were to be accepted and implemented. The current behaviour is an unnecessary implementation as far as I can tell, and makes code more verbose than necessary or desirable.The Solution
There are two possible solutions here. Firstly, to simply allow this coercion to be made. I don't see any fundamental contradictions here which would prevent this from working. Alternatively, #7812 would also address this, as
return
ing values would be separated fromthrow
ing errors.cc: @gracefuu
related: #5038 #7812
The text was updated successfully, but these errors were encountered: