diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-07-11 01:26:46 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-07-11 01:26:46 -0400 |
| commit | c6c49389ebd1503de38d9bb6ff6d9f6fba94d63b (patch) | |
| tree | 7fa287cbb79046159d03f06d546f2529afaf3388 /src-self-hosted | |
| parent | c620a1fe3d40d25d6b6654a4c828e8d7d7e37c38 (diff) | |
| download | zig-c6c49389ebd1503de38d9bb6ff6d9f6fba94d63b.tar.gz zig-c6c49389ebd1503de38d9bb6ff6d9f6fba94d63b.zip | |
self-hosted: add compile error test for missing fn name
Diffstat (limited to 'src-self-hosted')
| -rw-r--r-- | src-self-hosted/module.zig | 11 | ||||
| -rw-r--r-- | src-self-hosted/test.zig | 4 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src-self-hosted/module.zig b/src-self-hosted/module.zig index 44954e4cd1..4b0c44529b 100644 --- a/src-self-hosted/module.zig +++ b/src-self-hosted/module.zig @@ -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; }; diff --git a/src-self-hosted/test.zig b/src-self-hosted/test.zig index 01a857f21d..ffad7f1b8d 100644 --- a/src-self-hosted/test.zig +++ b/src-self-hosted/test.zig @@ -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(); } |
