authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-08-28 13:08:27+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-08-28 15:41:21+03:00
logfc213e2d61c9ae6e643ddebf502c699abe4055e8
treefdff78f15eb594b7d97bfd5ceacd1f5f733f1796
parent5bb8c03697fce798a966feb131f6d906863047ae

AstGen: add error for named function type

Closes #12660

2 files changed, 11 insertions(+), 0 deletions(-)

src/AstGen.zig+4
...@@ -1164,6 +1164,10 @@ fn fnProtoExpr(...@@ -1164,6 +1164,10 @@ fn fnProtoExpr(
1164 const tree = astgen.tree;1164 const tree = astgen.tree;
1165 const token_tags = tree.tokens.items(.tag);1165 const token_tags = tree.tokens.items(.tag);
11661166
1167 if (fn_proto.name_token) |some| {
1168 return astgen.failTok(some, "function type cannot have a name", .{});
1169 }
1170
1167 const is_extern = blk: {1171 const is_extern = blk: {
1168 const maybe_extern_token = fn_proto.extern_export_inline_token orelse break :blk false;1172 const maybe_extern_token = fn_proto.extern_export_inline_token orelse break :blk false;
1169 break :blk token_tags[maybe_extern_token] == .keyword_extern;1173 break :blk token_tags[maybe_extern_token] == .keyword_extern;
test/cases/compile_errors/function_type_named.zig created+7
...@@ -0,0 +1,7 @@
1const aFunc = fn someFunc(x: i32) void;
2
3// error
4// backend=stage2
5// target=native
6//
7// :1:18: error: function type cannot have a name