Skip to content

Commit

Permalink
fix test-stage2
Browse files Browse the repository at this point in the history
  • Loading branch information
nektro committed Aug 30, 2021
1 parent ab79e3b commit 1a1624e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/AstGen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10144,6 +10144,7 @@ fn scanDecls(astgen: *AstGen, namespace: *Scope.Namespace, members: []const ast.
const tree = astgen.tree;
const node_tags = tree.nodes.items(.tag);
const main_tokens = tree.nodes.items(.main_token);
const token_tags = tree.tokens.items(.tag);
for (members) |member_node| {
const name_token = switch (node_tags[member_node]) {
.fn_decl,
Expand Down Expand Up @@ -10174,6 +10175,7 @@ fn scanDecls(astgen: *AstGen, namespace: *Scope.Namespace, members: []const ast.
}
}

if (token_tags[name_token] != .identifier) return astgen.failNode(member_node, "missing function name", .{});
const name_str_index = try astgen.identAsString(name_token);
const gop = try namespace.decls.getOrPut(gpa, name_str_index);
if (gop.found_existing) {
Expand Down
13 changes: 4 additions & 9 deletions test/compile_errors.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4975,7 +4975,6 @@ pub fn addCases(ctx: *TestContext) !void {
\\fn b() void {}
, &[_][]const u8{
"tmp.zig:3:6: error: unreachable code",
"tmp.zig:2:5: note: control flow is diverted here",
});

ctx.objErrStage1("bad import",
Expand Down Expand Up @@ -5045,8 +5044,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ const a = return;
\\}
, &[_][]const u8{
"tmp.zig:2:5: error: unreachable code",
"tmp.zig:2:15: note: control flow is diverted here",
"tmp.zig:2:15: error: unreachable code",
});

ctx.objErrStage1("unreachable variable",
Expand Down Expand Up @@ -5281,8 +5279,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\}
\\export fn entry() void { _ = f(); }
, &[_][]const u8{
"tmp.zig:2:12: error: unreachable code",
"tmp.zig:2:21: note: control flow is diverted here",
"tmp.zig:2:21: error: unreachable code",
});

ctx.objErrStage1("invalid builtin fn",
Expand Down Expand Up @@ -7458,8 +7455,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ var z: noreturn = return;
\\}
, &[_][]const u8{
"tmp.zig:2:5: error: unreachable code",
"tmp.zig:2:23: note: control flow is diverted here",
"tmp.zig:2:23: error: unreachable code",
});

ctx.objErrStage1("wrong types given to atomic order args in cmpxchg",
Expand Down Expand Up @@ -7657,8 +7653,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ var allocator: ContextAllocator = undefined;
\\}
, &[_][]const u8{
"tmp.zig:4:5: error: unreachable code",
"tmp.zig:4:25: note: control flow is diverted here",
"tmp.zig:4:25: error: unreachable code",
"tmp.zig:12:9: error: unused local variable",
});

Expand Down

0 comments on commit 1a1624e

Please sign in to comment.