| ... | ... | @@ -3090,9 +3090,14 @@ fn lowerConstant(func: *CodeGen, arg_val: Value, ty: Type) InnerError!WValue { |
| 3090 | 3090 | }, |
| 3091 | 3091 | .ErrorUnion => { |
| 3092 | 3092 | 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", .{}); |
| 3096 | 3101 | }, |
| 3097 | 3102 | .Optional => if (ty.optionalReprIsPayload()) { |
| 3098 | 3103 | var buf: Type.Payload.ElemType = undefined; |