| author | |
| committer | |
| log | fc213e2d61c9ae6e643ddebf502c699abe4055e8 |
| tree | fdff78f15eb594b7d97bfd5ceacd1f5f733f1796 |
| parent | 5bb8c03697fce798a966feb131f6d906863047ae |
Closes #126602 files changed, 11 insertions(+), 0 deletions(-)
src/AstGen.zig+4| ... | ... | @@ -1164,6 +1164,10 @@ fn fnProtoExpr( |
| 1164 | 1164 | const tree = astgen.tree; |
| 1165 | 1165 | const token_tags = tree.tokens.items(.tag); |
| 1166 | 1166 | |
| 1167 | if (fn_proto.name_token) |some| { | |
| 1168 | return astgen.failTok(some, "function type cannot have a name", .{}); | |
| 1169 | } | |
| 1170 | ||
| 1167 | 1171 | const is_extern = blk: { |
| 1168 | 1172 | const maybe_extern_token = fn_proto.extern_export_inline_token orelse break :blk false; |
| 1169 | 1173 | break :blk token_tags[maybe_extern_token] == .keyword_extern; |
test/cases/compile_errors/function_type_named.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | const 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 |