| author | |
| committer | |
| log | 0977e4140768447e57474792ff42d056a8f2e0ed |
| tree | 67c87304105e594f6f1763077d607abf19e8a466 |
| parent | 60ea87340e7a7157bedbb43d60804ff0fb191ef9 |
| signature | Commit is signed but in an unrecognized format. |
3 files changed, 14 insertions(+), 1 deletions(-)
src-self-hosted/astgen.zig+5-1| ... | ... | @@ -600,7 +600,11 @@ const CondKind = union(enum) { |
| 600 | 600 | fn thenSubScope(self: CondKind, mod: *Module, then_scope: *Scope.GenZIR, src: usize, payload_node: ?*ast.Node) !*Scope { |
| 601 | 601 | if (self == .bool) return &then_scope.base; |
| 602 | 602 | |
| 603 | const payload = payload_node.?.castTag(.PointerPayload).?; | |
| 603 | const payload = payload_node.?.castTag(.PointerPayload) orelse { | |
| 604 | // condition is error union and payload is not explicitly ignored | |
| 605 | _ = try addZIRUnOp(mod, &then_scope.base, src, .ensure_err_payload_void, self.err_union.?); | |
| 606 | return &then_scope.base; | |
| 607 | }; | |
| 604 | 608 | const is_ptr = payload.ptr_token != null; |
| 605 | 609 | const ident_node = payload.value_symbol.castTag(.Identifier).?; |
| 606 | 610 |
src-self-hosted/zir.zig+4| ... | ... | @@ -225,6 +225,8 @@ pub const Inst = struct { |
| 225 | 225 | unwrap_err_safe, |
| 226 | 226 | /// Same as previous, but without safety checks. Used for orelse, if and while |
| 227 | 227 | unwrap_err_unsafe, |
| 228 | /// Takes a *E!T and raises a compiler error if T != void | |
| 229 | ensure_err_payload_void, | |
| 228 | 230 | |
| 229 | 231 | pub fn Type(tag: Tag) type { |
| 230 | 232 | return switch (tag) { |
| ... | ... | @@ -259,6 +261,7 @@ pub const Inst = struct { |
| 259 | 261 | .unwrap_optional_unsafe, |
| 260 | 262 | .unwrap_err_safe, |
| 261 | 263 | .unwrap_err_unsafe, |
| 264 | .ensure_err_payload_void, | |
| 262 | 265 | => UnOp, |
| 263 | 266 | |
| 264 | 267 | .add, |
| ... | ... | @@ -398,6 +401,7 @@ pub const Inst = struct { |
| 398 | 401 | .unwrap_err_safe, |
| 399 | 402 | .unwrap_err_unsafe, |
| 400 | 403 | .ptr_type, |
| 404 | .ensure_err_payload_void, | |
| 401 | 405 | => false, |
| 402 | 406 | |
| 403 | 407 | .@"break", |
src-self-hosted/zir_sema.zig+5| ... | ... | @@ -112,6 +112,7 @@ pub fn analyzeInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError! |
| 112 | 112 | .unwrap_optional_unsafe => return analyzeInstUnwrapOptional(mod, scope, old_inst.castTag(.unwrap_optional_unsafe).?, false), |
| 113 | 113 | .unwrap_err_safe => return analyzeInstUnwrapErr(mod, scope, old_inst.castTag(.unwrap_err_safe).?, true), |
| 114 | 114 | .unwrap_err_unsafe => return analyzeInstUnwrapErr(mod, scope, old_inst.castTag(.unwrap_err_unsafe).?, false), |
| 115 | .ensure_err_payload_void => return analyzeInstEnsureErrPayloadVoid(mod, scope, old_inst.castTag(.ensure_err_payload_void).?), | |
| 115 | 116 | } |
| 116 | 117 | } |
| 117 | 118 | |
| ... | ... | @@ -735,6 +736,10 @@ fn analyzeInstUnwrapErr(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp, saf |
| 735 | 736 | return mod.fail(scope, unwrap.base.src, "TODO implement analyzeInstUnwrapErr", .{}); |
| 736 | 737 | } |
| 737 | 738 | |
| 739 | fn analyzeInstEnsureErrPayloadVoid(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp) InnerError!*Inst { | |
| 740 | return mod.fail(scope, unwrap.base.src, "TODO implement analyzeInstEnsureErrPayloadVoid", .{}); | |
| 741 | } | |
| 742 | ||
| 738 | 743 | fn analyzeInstFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) InnerError!*Inst { |
| 739 | 744 | const return_type = try resolveType(mod, scope, fntype.positionals.return_type); |
| 740 | 745 |