Skip to content

Commit

Permalink
self-hosted: add compile error test for missing fn name
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Jul 11, 2018
1 parent c620a1f commit c6c4938
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src-self-hosted/module.zig
Expand Up @@ -347,13 +347,10 @@ pub const Module = struct {
const fn_proto = @fieldParentPtr(ast.Node.FnProto, "base", decl);

const name = if (fn_proto.name_token) |name_token| tree.tokenSlice(name_token) else {
@panic("TODO add compile error");
//try self.addCompileError(
// parsed_file,
// fn_proto.fn_token,
// fn_proto.fn_token + 1,
// "missing function name",
//);
try self.addCompileError(parsed_file, errmsg.Span{
.first = fn_proto.fn_token,
.last = fn_proto.fn_token + 1,
}, "missing function name");
continue;
};

Expand Down
4 changes: 4 additions & 0 deletions src-self-hosted/test.zig
Expand Up @@ -17,6 +17,10 @@ test "compile errors" {
\\export fn entry() void {}
, file1, 2, 8, "exported symbol collision: 'entry'");

try ctx.testCompileError(
\\fn() void {}
, file1, 1, 1, "missing function name");

try ctx.run();
}

Expand Down

0 comments on commit c6c4938

Please sign in to comment.