authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-26 13:16:33-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-26 21:10:54-07:00
logdbd44658ff2d392451ea4f3a38ca4bd26da34314
treead2d5ffed976e6c6e1a49d5b5297a50611081088
parent8f5f8090c5a58c41bf0ae7cec282c0949f459d2f

wasm backend: emit a TODO error rather than miscompile


1 files changed, 8 insertions(+), 3 deletions(-)

src/arch/wasm/CodeGen.zig+8-3
......@@ -3090,9 +3090,14 @@ fn lowerConstant(func: *CodeGen, arg_val: Value, ty: Type) InnerError!WValue {
30903090 },
30913091 .ErrorUnion => {
30923092 const error_type = ty.errorUnionSet();
3093 const is_pl = val.errorUnionIsPayload();
3094 const err_val = if (!is_pl) val else Value.initTag(.zero);
3095 return func.lowerConstant(err_val, error_type);
3093 const payload_type = ty.errorUnionPayload();
3094 if (!payload_type.hasRuntimeBitsIgnoreComptime()) {
3095 // We use the error type directly as the type.
3096 const is_pl = val.errorUnionIsPayload();
3097 const err_val = if (!is_pl) val else Value.initTag(.zero);
3098 return func.lowerConstant(err_val, error_type);
3099 }
3100 return func.fail("Wasm TODO: lowerConstant error union with non-zero-bit payload type", .{});
30963101 },
30973102 .Optional => if (ty.optionalReprIsPayload()) {
30983103 var buf: Type.Payload.ElemType = undefined;