| ... | ... | @@ -1722,8 +1722,16 @@ fn analyzeRootSrcFile(self: *Module, root_scope: *Scope.File) !void { |
| 1722 | 1722 | for (decls) |src_decl, decl_i| { |
| 1723 | 1723 | if (src_decl.cast(ast.Node.FnProto)) |fn_proto| { |
| 1724 | 1724 | // We will create a Decl for it regardless of analysis status. |
| 1725 | | const name_tok = fn_proto.name_token orelse |
| 1726 | | @panic("TODO handle missing function name in the parser"); |
| 1725 | const name_tok = fn_proto.name_token orelse { |
| 1726 | const err_msg = try ErrorMsg.create(self.allocator, tree.token_locs[fn_proto.firstToken()].end, "missing function name", .{}); |
| 1727 | // TODO: cache a single invalid decl in the Module? |
| 1728 | const new_decl = try self.createNewDecl(&root_scope.base, "", decl_i, [1]u8{0} ** 16, [1]u8{0} ** 16); |
| 1729 | root_scope.decls.appendAssumeCapacity(new_decl); |
| 1730 | errdefer err_msg.destroy(self.allocator); |
| 1731 | try self.failed_decls.putNoClobber(new_decl, err_msg); |
| 1732 | continue; |
| 1733 | }; |
| 1734 | |
| 1727 | 1735 | const name_loc = tree.token_locs[name_tok]; |
| 1728 | 1736 | const name = tree.tokenSliceLoc(name_loc); |
| 1729 | 1737 | const name_hash = root_scope.fullyQualifiedNameHash(name); |
| ... | ... | @@ -1734,6 +1742,7 @@ fn analyzeRootSrcFile(self: *Module, root_scope: *Scope.File) !void { |
| 1734 | 1742 | // have been re-ordered. |
| 1735 | 1743 | decl.src_index = decl_i; |
| 1736 | 1744 | if (deleted_decls.remove(decl) == null) { |
| 1745 | decl.analysis = .sema_failure; |
| 1737 | 1746 | const err_msg = try ErrorMsg.create(self.allocator, tree.token_locs[name_tok].start, "redefinition of '{}'", .{decl.name}); |
| 1738 | 1747 | errdefer err_msg.destroy(self.allocator); |
| 1739 | 1748 | try self.failed_decls.putNoClobber(decl, err_msg); |