| author | |
| committer | |
| log | 6510888039baaa0058a7e2bade2750569af1abbd |
| tree | 1c2254e5d22d4e2d72b2f21c78094589689d0baf |
| parent | 4a17e008daa90d5dbb0fc917d53e52c1ec990f2d |
| signature | Commit is signed but in an unrecognized format. |
2 files changed, 28 insertions(+), 9 deletions(-)
src-self-hosted/Module.zig+9-4| ... | @@ -1733,10 +1733,15 @@ fn analyzeRootSrcFile(self: *Module, root_scope: *Scope.File) !void { | ... | @@ -1733,10 +1733,15 @@ fn analyzeRootSrcFile(self: *Module, root_scope: *Scope.File) !void { |
| 1733 | // Update the AST Node index of the decl, even if its contents are unchanged, it may | 1733 | // Update the AST Node index of the decl, even if its contents are unchanged, it may |
| 1734 | // have been re-ordered. | 1734 | // have been re-ordered. |
| 1735 | decl.src_index = decl_i; | 1735 | decl.src_index = decl_i; |
| 1736 | deleted_decls.removeAssertDiscard(decl); | 1736 | if (deleted_decls.remove(decl) == null) { |
| 1737 | if (!srcHashEql(decl.contents_hash, contents_hash)) { | 1737 | const err_msg = try ErrorMsg.create(self.allocator, tree.token_locs[name_tok].start, "redefinition of '{}'", .{decl.name}); |
| 1738 | try self.markOutdatedDecl(decl); | 1738 | errdefer err_msg.destroy(self.allocator); |
| 1739 | decl.contents_hash = contents_hash; | 1739 | try self.failed_decls.putNoClobber(decl, err_msg); |
| 1740 | } else { | ||
| 1741 | if (!srcHashEql(decl.contents_hash, contents_hash)) { | ||
| 1742 | try self.markOutdatedDecl(decl); | ||
| 1743 | decl.contents_hash = contents_hash; | ||
| 1744 | } | ||
| 1740 | } | 1745 | } |
| 1741 | } else { | 1746 | } else { |
| 1742 | const new_decl = try self.createNewDecl(&root_scope.base, name, decl_i, name_hash, contents_hash); | 1747 | const new_decl = try self.createNewDecl(&root_scope.base, name, decl_i, name_hash, contents_hash); |
test/stage2/compile_errors.zig+19-5| ... | @@ -67,14 +67,28 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -67,14 +67,28 @@ pub fn addCases(ctx: *TestContext) !void { |
| 67 | \\@1 = export(@0, "start") | 67 | \\@1 = export(@0, "start") |
| 68 | ); | 68 | ); |
| 69 | } | 69 | } |
| 70 | // TODO: need to make sure this works with other variants of export. | ||
| 71 | // As is, the same error occurs without export. | ||
| 72 | { | ||
| 73 | var case = ctx.obj("exported symbol collision", linux_x64); | ||
| 74 | case.addError( | ||
| 75 | \\export fn entry() void {} | ||
| 76 | \\export fn entry() void {} | ||
| 77 | , &[_][]const u8{":2:11: error: redefinition of 'entry'"}); | ||
| 78 | case.compiles( | ||
| 79 | \\export fn entry() void {} | ||
| 80 | ); | ||
| 81 | case.addError( | ||
| 82 | \\fn entry() void {} | ||
| 83 | \\fn entry() void {} | ||
| 84 | , &[_][]const u8{":2:4: error: redefinition of 'entry'"}); | ||
| 85 | case.compiles( | ||
| 86 | \\export fn entry() void {} | ||
| 87 | ); | ||
| 88 | } | ||
| 70 | // TODO: re-enable these tests. | 89 | // TODO: re-enable these tests. |
| 71 | // https://github.com/ziglang/zig/issues/1364 | 90 | // https://github.com/ziglang/zig/issues/1364 |
| 72 | 91 | ||
| 73 | // ctx.compileError("Export same symbol twice", linux_x64, | ||
| 74 | // \\export fn entry() void {} | ||
| 75 | // \\export fn entry() void {} | ||
| 76 | // , &[_][]const u8{":2:1: error: exported symbol collision"}); | ||
| 77 | |||
| 78 | // ctx.addError("Missing function name", linux_x64, .Zig, | 92 | // ctx.addError("Missing function name", linux_x64, .Zig, |
| 79 | // \\fn() void {} | 93 | // \\fn() void {} |
| 80 | // , &[_][]const u8{":1:3: error: missing function name"}); | 94 | // , &[_][]const u8{":1:3: error: missing function name"}); |