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
{{ message }}
This repository was archived by the owner on Aug 17, 2022. It is now read-only.
There is no way to add new error cases to that enum without breaking backwards compatibility, since the enum is used in a return position. Note that this problem does not occur when the enum is used as a parameter.
As it stands with the current Interface Types proposal; to work around this limitation we have to resort to returning meaningless integers (or any other type of artificial constant):
I suggest adding some kind of annotation to variant types that optionally marks a single case as the fallback that future additions resolve to. For example:
Because $Errno2 has a fallback case, $Errno3 can now be coerced into $Errno2. All cases of $Errno3 not present in $Errno2 will be coerced to $Errno2s fallback case: "unknown". This does mean data might be discarded during coercion, however I'd argue this is OK since you'd have to explicitly op-in to this behavior in the original type.
Restrictions:
Only constructor-less cases can be marked as fallback, ie cases that carry no additional data.