diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-02-19 11:35:49 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-02-19 20:21:19 +0200 |
| commit | e02749224357a33cffcaf9970d14c199adc3d892 (patch) | |
| tree | 90970730e6d00583eeb8789e035d1f1dd8edc466 /src/AstGen.zig | |
| parent | 2f0204aca303daf899a97c740719a62398adc206 (diff) | |
| download | zig-e02749224357a33cffcaf9970d14c199adc3d892.tar.gz zig-e02749224357a33cffcaf9970d14c199adc3d892.zip | |
stage2: support anon init through error unions and optionals
Diffstat (limited to 'src/AstGen.zig')
| -rw-r--r-- | src/AstGen.zig | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig index 0652a6232f..8f34a58ed4 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -1384,7 +1384,8 @@ fn arrayInitExprRlPtr( array_ty: Zir.Inst.Ref, ) InnerError!Zir.Inst.Ref { if (array_ty == .none) { - return arrayInitExprRlPtrInner(gz, scope, node, result_ptr, elements); + const base_ptr = try gz.addUnNode(.array_base_ptr, result_ptr, node); + return arrayInitExprRlPtrInner(gz, scope, node, base_ptr, elements); } var as_scope = try gz.makeCoercionScope(scope, array_ty, result_ptr); @@ -1493,6 +1494,7 @@ fn structInitExpr( switch (rl) { .discard => { + // TODO if a type expr is given the fields should be validated for that type if (struct_init.ast.type_expr != 0) _ = try typeExpr(gz, scope, struct_init.ast.type_expr); for (struct_init.ast.fields) |field_init| { @@ -1567,7 +1569,8 @@ fn structInitExprRlPtr( result_ptr: Zir.Inst.Ref, ) InnerError!Zir.Inst.Ref { if (struct_init.ast.type_expr == 0) { - return structInitExprRlPtrInner(gz, scope, node, struct_init, result_ptr); + const base_ptr = try gz.addUnNode(.field_base_ptr, result_ptr, node); + return structInitExprRlPtrInner(gz, scope, node, struct_init, base_ptr); } const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); @@ -2281,6 +2284,8 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner .ret_err_value_code, .extended, .closure_get, + .array_base_ptr, + .field_base_ptr, => break :b false, // ZIR instructions that are always `noreturn`. |
