| ... | @@ -133,8 +133,6 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { | ... | @@ -133,8 +133,6 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { |
| 133 | try astgen.extra.ensureTotalCapacity(gpa, tree.nodes.len + reserved_count); | 133 | try astgen.extra.ensureTotalCapacity(gpa, tree.nodes.len + reserved_count); |
| 134 | astgen.extra.items.len += reserved_count; | 134 | astgen.extra.items.len += reserved_count; |
| 135 | | 135 | |
| 136 | try lowerAstErrors(&astgen); | | |
| 137 | | | |
| 138 | var top_scope: Scope.Top = .{}; | 136 | var top_scope: Scope.Top = .{}; |
| 139 | | 137 | |
| 140 | var gz_instructions: std.ArrayListUnmanaged(Zir.Inst.Index) = .{}; | 138 | var gz_instructions: std.ArrayListUnmanaged(Zir.Inst.Index) = .{}; |
| ... | @@ -150,18 +148,24 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { | ... | @@ -150,18 +148,24 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { |
| 150 | }; | 148 | }; |
| 151 | defer gz_instructions.deinit(gpa); | 149 | defer gz_instructions.deinit(gpa); |
| 152 | | 150 | |
| 153 | if (AstGen.structDeclInner( | 151 | // The AST -> ZIR lowering process assumes an AST that does not have any |
| 154 | &gen_scope, | 152 | // parse errors. |
| 155 | &gen_scope.base, | 153 | if (tree.errors.len == 0) { |
| 156 | 0, | 154 | if (AstGen.structDeclInner( |
| 157 | tree.containerDeclRoot(), | 155 | &gen_scope, |
| 158 | .Auto, | 156 | &gen_scope.base, |
| 159 | 0, | 157 | 0, |
| 160 | )) |struct_decl_ref| { | 158 | tree.containerDeclRoot(), |
| 161 | assert(refToIndex(struct_decl_ref).? == 0); | 159 | .Auto, |
| 162 | } else |err| switch (err) { | 160 | 0, |
| 163 | error.OutOfMemory => return error.OutOfMemory, | 161 | )) |struct_decl_ref| { |
| 164 | error.AnalysisFail => {}, // Handled via compile_errors below. | 162 | assert(refToIndex(struct_decl_ref).? == 0); |
| | 163 | } else |err| switch (err) { |
| | 164 | error.OutOfMemory => return error.OutOfMemory, |
| | 165 | error.AnalysisFail => {}, // Handled via compile_errors below. |
| | 166 | } |
| | 167 | } else { |
| | 168 | try lowerAstErrors(&astgen); |
| 165 | } | 169 | } |
| 166 | | 170 | |
| 167 | const err_index = @enumToInt(Zir.ExtraIndex.compile_errors); | 171 | const err_index = @enumToInt(Zir.ExtraIndex.compile_errors); |
| ... | @@ -12642,7 +12646,7 @@ fn emitDbgStmt(gz: *GenZir, line: u32, column: u32) !void { | ... | @@ -12642,7 +12646,7 @@ fn emitDbgStmt(gz: *GenZir, line: u32, column: u32) !void { |
| 12642 | | 12646 | |
| 12643 | fn lowerAstErrors(astgen: *AstGen) !void { | 12647 | fn lowerAstErrors(astgen: *AstGen) !void { |
| 12644 | const tree = astgen.tree; | 12648 | const tree = astgen.tree; |
| 12645 | if (tree.errors.len == 0) return; | 12649 | assert(tree.errors.len > 0); |
| 12646 | | 12650 | |
| 12647 | const gpa = astgen.gpa; | 12651 | const gpa = astgen.gpa; |
| 12648 | const parse_err = tree.errors[0]; | 12652 | const parse_err = tree.errors[0]; |