authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-11 01:26:46-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-11 01:26:46-04:00
logc6c49389ebd1503de38d9bb6ff6d9f6fba94d63b
tree7fa287cbb79046159d03f06d546f2529afaf3388
parentc620a1fe3d40d25d6b6654a4c828e8d7d7e37c38

self-hosted: add compile error test for missing fn name


2 files changed, 8 insertions(+), 7 deletions(-)

src-self-hosted/module.zig+4-7
...@@ -347,13 +347,10 @@ pub const Module = struct {...@@ -347,13 +347,10 @@ pub const Module = struct {
347 const fn_proto = @fieldParentPtr(ast.Node.FnProto, "base", decl);347 const fn_proto = @fieldParentPtr(ast.Node.FnProto, "base", decl);
348348
349 const name = if (fn_proto.name_token) |name_token| tree.tokenSlice(name_token) else {349 const name = if (fn_proto.name_token) |name_token| tree.tokenSlice(name_token) else {
350 @panic("TODO add compile error");350 try self.addCompileError(parsed_file, errmsg.Span{
351 //try self.addCompileError(351 .first = fn_proto.fn_token,
352 // parsed_file,352 .last = fn_proto.fn_token + 1,
353 // fn_proto.fn_token,353 }, "missing function name");
354 // fn_proto.fn_token + 1,
355 // "missing function name",
356 //);
357 continue;354 continue;
358 };355 };
359356
src-self-hosted/test.zig+4
...@@ -17,6 +17,10 @@ test "compile errors" {...@@ -17,6 +17,10 @@ test "compile errors" {
17 \\export fn entry() void {}17 \\export fn entry() void {}
18 , file1, 2, 8, "exported symbol collision: 'entry'");18 , file1, 2, 8, "exported symbol collision: 'entry'");
1919
20 try ctx.testCompileError(
21 \\fn() void {}
22 , file1, 1, 1, "missing function name");
23
20 try ctx.run();24 try ctx.run();
21}25}
2226