authorgravatar for 58830309+g-w1@users.noreply.github.comg-w1 <58830309+g-w1@users.noreply.github.com> 2021-07-08 14:35:43-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-07-08 14:35:43-04:00
log1f0b77b3b88112ef458f62c23df72003c843e7cc
tree14c1b4f803df6474bb84ff902e65e002fec26292
parenta201d80253c79bd6a024cc3dfdad803570fe6c3b
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

stage2 type.zig: implement eql of error unions (#9334)


2 files changed, 16 insertions(+), 1 deletions(-)

src/type.zig+5-1
......@@ -520,9 +520,13 @@ pub const Type = extern union {
520520 }
521521 return a.tag() == b.tag();
522522 },
523 .ErrorUnion => {
524 const a_data = a.castTag(.error_union).?.data;
525 const b_data = b.castTag(.error_union).?.data;
526 return a_data.error_set.eql(b_data.error_set) and a_data.payload.eql(b_data.payload);
527 },
523528 .Opaque,
524529 .Float,
525 .ErrorUnion,
526530 .ErrorSet,
527531 .BoundFn,
528532 .Frame,
test/stage2/wasm.zig+11
......@@ -600,5 +600,16 @@ pub fn addCases(ctx: *TestContext) !void {
600600 \\ return error.Bruh;
601601 \\}
602602 , "69\n");
603 case.addCompareOutput(
604 \\pub export fn _start() u32 {
605 \\ var e = foo();
606 \\ const i = e catch 42;
607 \\ return i;
608 \\}
609 \\
610 \\fn foo() anyerror!u32 {
611 \\ return error.Dab;
612 \\}
613 , "42\n");
603614 }
604615}