-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
acceptedThis proposal is planned.This proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Description
The type makes no sense and cannot be created:
test {
const E = error{Foo};
// error: expected type 'E', found 'error{Bar}'
var a: E!anyerror = error.Bar;
// error: expected type 'E', found 'anyerror'
var b: anyerror = error.Bar;
var a: E!anyerror = b;
// panic: invalid error code
var b: anyerror = error.Bar;
var a: E!anyerror = @errSetCast(E, b);
// panic: reached unreachable code
@setRuntimeSafety(false);
var b: anyerror = error.Bar;
var a: E!anyerror = @errSetCast(E, b);
var discard = a catch @import("std").debug.assert(false);
}
// This does work but hardly justifies its existence.
const E = error{Foo};
const E2 = error{Bar};
const S = struct { payload: E2, err: u16 };
test {
var a: E!E2 = undefined;
a = @bitCast(E!E2, S{ .payload = E2.Bar, .err = 0 });
var foo = a catch unreachable;
}czrptrdaurnimator
Metadata
Metadata
Assignees
Labels
acceptedThis proposal is planned.This proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.