authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2023-07-04 10:34:31-04:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-09-19 15:15:05+03:00
logee4ced96833470f9432e6a5dc5b31534457280c0
tree8d35dc654895f029e23ce710367b839814ed5cd9
parent3e79315d19c7dfe5f9b90185d8030209ef8dd829

write function types consistently with a space before `fn` keyword

Currently, the compiler (like @typeName) writes it `fn(...) Type` but zig fmt writes it `fn (...) Type` (notice the space after `fn`). This inconsistency is now resolved and function types are consistently written the zig fmt way. Before this there were more `fn (...) Type` occurrences than `fn(...) Type` already.

43 files changed, 91 insertions(+), 91 deletions(-)

lib/std/atomic/Atomic.zig+1-1
......@@ -21,7 +21,7 @@ pub fn Atomic(comptime T: type) type {
2121 /// ```
2222 /// const RefCount = struct {
2323 /// count: Atomic(usize),
24 /// dropFn: *const fn(*RefCount) void,
24 /// dropFn: *const fn (*RefCount) void,
2525 ///
2626 /// fn ref(self: *RefCount) void {
2727 /// _ = self.count.fetchAdd(1, .Monotonic); // no ordering necessary, just updating a counter
lib/std/enums.zig+4-4
......@@ -1269,10 +1269,10 @@ pub fn ensureIndexer(comptime T: type) void {
12691269 if (@TypeOf(T.Key) != type) @compileError("Indexer.Key must be a type.");
12701270 if (!@hasDecl(T, "count")) @compileError("Indexer must have decl count: usize.");
12711271 if (@TypeOf(T.count) != usize) @compileError("Indexer.count must be a usize.");
1272 if (!@hasDecl(T, "indexOf")) @compileError("Indexer.indexOf must be a fn(Key)usize.");
1273 if (@TypeOf(T.indexOf) != fn (T.Key) usize) @compileError("Indexer must have decl indexOf: fn(Key)usize.");
1274 if (!@hasDecl(T, "keyForIndex")) @compileError("Indexer must have decl keyForIndex: fn(usize)Key.");
1275 if (@TypeOf(T.keyForIndex) != fn (usize) T.Key) @compileError("Indexer.keyForIndex must be a fn(usize)Key.");
1272 if (!@hasDecl(T, "indexOf")) @compileError("Indexer.indexOf must be a fn (Key) usize.");
1273 if (@TypeOf(T.indexOf) != fn (T.Key) usize) @compileError("Indexer must have decl indexOf: fn (Key) usize.");
1274 if (!@hasDecl(T, "keyForIndex")) @compileError("Indexer must have decl keyForIndex: fn (usize) Key.");
1275 if (@TypeOf(T.keyForIndex) != fn (usize) T.Key) @compileError("Indexer.keyForIndex must be a fn (usize) Key.");
12761276 }
12771277}
12781278
lib/std/fmt.zig+2-2
......@@ -2255,11 +2255,11 @@ test "pointer" {
22552255 const FnPtr = *align(1) const fn () void;
22562256 {
22572257 const value = @as(FnPtr, @ptrFromInt(0xdeadbeef));
2258 try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value});
2258 try expectFmt("pointer: fn () void@deadbeef\n", "pointer: {}\n", .{value});
22592259 }
22602260 {
22612261 const value = @as(FnPtr, @ptrFromInt(0xdeadbeef));
2262 try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value});
2262 try expectFmt("pointer: fn () void@deadbeef\n", "pointer: {}\n", .{value});
22632263 }
22642264}
22652265
lib/std/meta.zig+3-3
......@@ -969,9 +969,9 @@ test "std.meta.Float" {
969969/// correspond to the argument types.
970970///
971971/// Examples:
972/// - `ArgsTuple(fn() void)` ⇒ `tuple { }`
973/// - `ArgsTuple(fn(a: u32) u32)` ⇒ `tuple { u32 }`
974/// - `ArgsTuple(fn(a: u32, b: f16) noreturn)` ⇒ `tuple { u32, f16 }`
972/// - `ArgsTuple(fn () void)` ⇒ `tuple { }`
973/// - `ArgsTuple(fn (a: u32) u32)` ⇒ `tuple { u32 }`
974/// - `ArgsTuple(fn (a: u32, b: f16) noreturn)` ⇒ `tuple { u32, f16 }`
975975pub fn ArgsTuple(comptime Function: type) type {
976976 const info = @typeInfo(Function);
977977 if (info != .Fn)
lib/std/treap.zig+1-1
......@@ -7,7 +7,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
77 return struct {
88 const Self = @This();
99
10 // Allow for compareFn to be fn(anytype, anytype) anytype
10 // Allow for compareFn to be fn (anytype, anytype) anytype
1111 // which allows the convenient use of std.math.order.
1212 fn compare(a: Key, b: Key) Order {
1313 return compareFn(a, b);
lib/std/zig/Ast.zig+4-4
......@@ -3255,23 +3255,23 @@ pub const Node = struct {
32553255 @"break",
32563256 /// `return lhs`. lhs can be omitted. rhs is unused.
32573257 @"return",
3258 /// `fn(a: lhs) rhs`. lhs can be omitted.
3258 /// `fn (a: lhs) rhs`. lhs can be omitted.
32593259 /// anytype and ... parameters are omitted from the AST tree.
32603260 /// main_token is the `fn` keyword.
32613261 /// extern function declarations use this tag.
32623262 fn_proto_simple,
3263 /// `fn(a: b, c: d) rhs`. `sub_range_list[lhs]`.
3263 /// `fn (a: b, c: d) rhs`. `sub_range_list[lhs]`.
32643264 /// anytype and ... parameters are omitted from the AST tree.
32653265 /// main_token is the `fn` keyword.
32663266 /// extern function declarations use this tag.
32673267 fn_proto_multi,
3268 /// `fn(a: b) rhs addrspace(e) linksection(f) callconv(g)`. `FnProtoOne[lhs]`.
3268 /// `fn (a: b) rhs addrspace(e) linksection(f) callconv(g)`. `FnProtoOne[lhs]`.
32693269 /// zero or one parameters.
32703270 /// anytype and ... parameters are omitted from the AST tree.
32713271 /// main_token is the `fn` keyword.
32723272 /// extern function declarations use this tag.
32733273 fn_proto_one,
3274 /// `fn(a: b, c: d) rhs addrspace(e) linksection(f) callconv(g)`. `FnProto[lhs]`.
3274 /// `fn (a: b, c: d) rhs addrspace(e) linksection(f) callconv(g)`. `FnProto[lhs]`.
32753275 /// anytype and ... parameters are omitted from the AST tree.
32763276 /// main_token is the `fn` keyword.
32773277 /// extern function declarations use this tag.
lib/std/zig/parser_test.zig+2-2
......@@ -5251,8 +5251,8 @@ test "zig fmt: make single-line if no trailing comma, fmt: off" {
52515251 \\ }
52525252 \\}
52535253 \\
5254 \\const fn_no_comma = fn(i32, i32)void;
5255 \\const fn_trailing_comma = fn(i32, i32,)void;
5254 \\const fn_no_comma = fn (i32, i32) void;
5255 \\const fn_trailing_comma = fn (i32, i32,) void;
52565256 \\
52575257 \\fn fn_calls() void {
52585258 \\ fn add(x: i32, y: i32,) i32 { x + y };
src/Sema.zig+1-1
......@@ -6722,7 +6722,7 @@ fn zirCall(
67226722 {
67236723 const return_ty = sema.typeOf(call_inst);
67246724 if (modifier != .always_tail and return_ty.isNoReturn(mod))
6725 return call_inst; // call to "fn(...) noreturn", don't pop
6725 return call_inst; // call to "fn (...) noreturn", don't pop
67266726
67276727 // TODO: we don't fix up the error trace for always_tail correctly, we should be doing it
67286728 // *before* the recursive call. This will be a bit tricky to do and probably requires
src/type.zig+1-1
......@@ -364,7 +364,7 @@ pub const Type = struct {
364364 if (fn_info.is_noinline) {
365365 try writer.writeAll("noinline ");
366366 }
367 try writer.writeAll("fn(");
367 try writer.writeAll("fn (");
368368 const param_types = fn_info.param_types.get(&mod.intern_pool);
369369 for (param_types, 0..) |param_ty, i| {
370370 if (i != 0) try writer.writeAll(", ");
test/behavior/cast.zig+1-1
......@@ -1194,7 +1194,7 @@ test "implicit ptr to *anyopaque" {
11941194 try expect(c.* == 1);
11951195}
11961196
1197test "return null from fn() anyerror!?&T" {
1197test "return null from fn () anyerror!?&T" {
11981198 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
11991199 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
12001200 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
test/behavior/typename.zig+16-16
......@@ -73,18 +73,18 @@ test "basic" {
7373 try expectEqualStrings("*usize", @typeName(*usize));
7474 try expectEqualStrings("[]u8", @typeName([]u8));
7575
76 try expectEqualStrings("fn() void", @typeName(fn () void));
77 try expectEqualStrings("fn(u32) void", @typeName(fn (u32) void));
78 try expectEqualStrings("fn(u32) void", @typeName(fn (a: u32) void));
79
80 try expectEqualStrings("fn(comptime u32) void", @typeName(fn (comptime u32) void));
81 try expectEqualStrings("fn(noalias []u8) void", @typeName(fn (noalias []u8) void));
82
83 try expectEqualStrings("fn() align(32) void", @typeName(fn () align(32) void));
84 try expectEqualStrings("fn() callconv(.C) void", @typeName(fn () callconv(.C) void));
85 try expectEqualStrings("fn() align(32) callconv(.C) void", @typeName(fn () align(32) callconv(.C) void));
86 try expectEqualStrings("fn(...) align(32) callconv(.C) void", @typeName(fn (...) align(32) callconv(.C) void));
87 try expectEqualStrings("fn(u32, ...) align(32) callconv(.C) void", @typeName(fn (u32, ...) align(32) callconv(.C) void));
76 try expectEqualStrings("fn () void", @typeName(fn () void));
77 try expectEqualStrings("fn (u32) void", @typeName(fn (u32) void));
78 try expectEqualStrings("fn (u32) void", @typeName(fn (a: u32) void));
79
80 try expectEqualStrings("fn (comptime u32) void", @typeName(fn (comptime u32) void));
81 try expectEqualStrings("fn (noalias []u8) void", @typeName(fn (noalias []u8) void));
82
83 try expectEqualStrings("fn () align(32) void", @typeName(fn () align(32) void));
84 try expectEqualStrings("fn () callconv(.C) void", @typeName(fn () callconv(.C) void));
85 try expectEqualStrings("fn () align(32) callconv(.C) void", @typeName(fn () align(32) callconv(.C) void));
86 try expectEqualStrings("fn (...) align(32) callconv(.C) void", @typeName(fn (...) align(32) callconv(.C) void));
87 try expectEqualStrings("fn (u32, ...) align(32) callconv(.C) void", @typeName(fn (u32, ...) align(32) callconv(.C) void));
8888}
8989
9090test "top level decl" {
......@@ -108,17 +108,17 @@ test "top level decl" {
108108
109109 // regular fn, without error
110110 try expectEqualStrings(
111 "fn() void",
111 "fn () void",
112112 @typeName(@TypeOf(regular)),
113113 );
114114 // regular fn inside struct, with error
115115 try expectEqualStrings(
116 "fn() @typeInfo(@typeInfo(@TypeOf(behavior.typename.B.doTest)).Fn.return_type.?).ErrorUnion.error_set!void",
116 "fn () @typeInfo(@typeInfo(@TypeOf(behavior.typename.B.doTest)).Fn.return_type.?).ErrorUnion.error_set!void",
117117 @typeName(@TypeOf(B.doTest)),
118118 );
119119 // generic fn
120120 try expectEqualStrings(
121 "fn(comptime type) type",
121 "fn (comptime type) type",
122122 @typeName(@TypeOf(TypeFromFn)),
123123 );
124124}
......@@ -234,7 +234,7 @@ test "comptime parameters not converted to anytype in function type" {
234234 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
235235
236236 const T = fn (fn (type) void, void) void;
237 try expectEqualStrings("fn(comptime fn(comptime type) void, void) void", @typeName(T));
237 try expectEqualStrings("fn (comptime fn (comptime type) void, void) void", @typeName(T));
238238}
239239
240240test "anon name strategy used in sub expression" {
test/cases/compile_errors/AstGen_comptime_known_struct_is_resolved_before_error.zig+1-1
......@@ -16,4 +16,4 @@ pub export fn entry() void {
1616// :8:12: error: variable of type 'tmp.S1' must be const or comptime
1717// :2:8: note: struct requires comptime because of this field
1818// :5:8: note: struct requires comptime because of this field
19// :5:8: note: use '*const fn() void' for a function pointer type
19// :5:8: note: use '*const fn () void' for a function pointer type
test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig+1-1
......@@ -8,5 +8,5 @@ inline fn b() void {}
88// backend=stage2
99// target=native
1010//
11// :2:9: error: variable of type '*const fn() callconv(.Inline) void' must be const or comptime
11// :2:9: error: variable of type '*const fn () callconv(.Inline) void' must be const or comptime
1212// :2:9: note: function has inline calling convention
test/cases/compile_errors/async/non_async_function_pointer_passed_to_asyncCall.zig+1-1
......@@ -9,4 +9,4 @@ fn afunc() void {}
99// backend=stage1
1010// target=native
1111//
12// tmp.zig:4:32: error: expected async function, found 'fn() void'
12// tmp.zig:4:32: error: expected async function, found 'fn () void'
test/cases/compile_errors/call_optional_function.zig+2-2
......@@ -11,7 +11,7 @@ pub export fn entry2() void {
1111// backend=stage2
1212// target=native
1313//
14// :3:9: error: cannot call optional type '?fn() void'
14// :3:9: error: cannot call optional type '?fn () void'
1515// :3:9: note: consider using '.?', 'orelse' or 'if'
16// :7:9: error: cannot call optional type '?*const fn() void'
16// :7:9: error: cannot call optional type '?*const fn () void'
1717// :7:9: note: consider using '.?', 'orelse' or 'if'
test/cases/compile_errors/cast_between_optional_T_where_T_is_not_a_pointer.zig+4-4
......@@ -17,10 +17,10 @@ export fn entry2() void {
1717// backend=stage2
1818// target=native
1919//
20// :6:9: error: expected type '?*const fn(i8) void', found '?*const fn(u64) void'
21// :6:9: note: pointer type child 'fn(u64) void' cannot cast into pointer type child 'fn(i8) void'
20// :6:9: error: expected type '?*const fn (i8) void', found '?*const fn (u64) void'
21// :6:9: note: pointer type child 'fn (u64) void' cannot cast into pointer type child 'fn (i8) void'
2222// :6:9: note: parameter 0 'u64' cannot cast into 'i8'
2323// :6:9: note: unsigned 64-bit int cannot represent all possible signed 8-bit values
24// :13:9: error: expected type '?*const fn(u63) void', found '?*const fn(u64) void'
25// :13:9: note: pointer type child 'fn(u64) void' cannot cast into pointer type child 'fn(u63) void'
24// :13:9: error: expected type '?*const fn (u63) void', found '?*const fn (u64) void'
25// :13:9: note: pointer type child 'fn (u64) void' cannot cast into pointer type child 'fn (u63) void'
2626// :13:9: note: parameter 0 'u64' cannot cast into 'u63'
test/cases/compile_errors/comptime_param_coersion.zig+2-2
......@@ -14,7 +14,7 @@ fn bar(comptime _: i32, _: i32) void {}
1414// backend=stage2
1515// target=native
1616//
17// :3:9: error: expected type 'fn(comptime i32, comptime i32) void', found 'fn(comptime i32, i32) void'
17// :3:9: error: expected type 'fn (comptime i32, comptime i32) void', found 'fn (comptime i32, i32) void'
1818// :3:9: note: non-comptime parameter 1 cannot cast into a comptime parameter
19// :7:9: error: expected type 'fn(i32, i32) void', found 'fn(comptime i32, comptime i32) void'
19// :7:9: error: expected type 'fn (i32, i32) void', found 'fn (comptime i32, comptime i32) void'
2020// :7:9: note: generic function cannot cast into a non-generic function
test/cases/compile_errors/comptime_parameter_not_declared_as_such.zig+1-1
......@@ -20,6 +20,6 @@ pub export fn entry1() void {
2020// backend=stage2
2121// target=native
2222//
23// :3:6: error: parameter of type '*const fn(anytype) void' must be declared comptime
23// :3:6: error: parameter of type '*const fn (anytype) void' must be declared comptime
2424// :3:6: note: function is generic
2525// :10:34: error: parameter of type 'comptime_int' must be declared comptime
test/cases/compile_errors/condition_comptime_reason_explained.zig+2-2
......@@ -40,11 +40,11 @@ pub export fn entry2() void {
4040// :8:9: note: condition in comptime branch must be comptime-known
4141// :7:13: note: expression is evaluated at comptime because the function returns a comptime-only type 'tmp.S'
4242// :2:12: note: struct requires comptime because of this field
43// :2:12: note: use '*const fn() void' for a function pointer type
43// :2:12: note: use '*const fn () void' for a function pointer type
4444// :19:15: note: called from here
4545// :22:13: error: unable to resolve comptime value
4646// :22:13: note: condition in comptime switch must be comptime-known
4747// :21:17: note: expression is evaluated at comptime because the function returns a comptime-only type 'tmp.S'
4848// :2:12: note: struct requires comptime because of this field
49// :2:12: note: use '*const fn() void' for a function pointer type
49// :2:12: note: use '*const fn () void' for a function pointer type
5050// :32:19: note: called from here
test/cases/compile_errors/dereference_anyopaque.zig+6-6
......@@ -46,9 +46,9 @@ pub export fn entry() void {
4646//
4747// :11:22: error: comparison of 'void' with null
4848// :25:51: error: cannot load opaque type 'anyopaque'
49// :25:51: error: values of type 'fn(*anyopaque, usize, u8, usize) ?[*]u8' must be comptime-known, but operand value is runtime-known
50// :25:51: note: use '*const fn(*anyopaque, usize, u8, usize) ?[*]u8' for a function pointer type
51// :25:51: error: values of type 'fn(*anyopaque, []u8, u8, usize, usize) bool' must be comptime-known, but operand value is runtime-known
52// :25:51: note: use '*const fn(*anyopaque, []u8, u8, usize, usize) bool' for a function pointer type
53// :25:51: error: values of type 'fn(*anyopaque, []u8, u8, usize) void' must be comptime-known, but operand value is runtime-known
54// :25:51: note: use '*const fn(*anyopaque, []u8, u8, usize) void' for a function pointer type
49// :25:51: error: values of type 'fn (*anyopaque, usize, u8, usize) ?[*]u8' must be comptime-known, but operand value is runtime-known
50// :25:51: note: use '*const fn (*anyopaque, usize, u8, usize) ?[*]u8' for a function pointer type
51// :25:51: error: values of type 'fn (*anyopaque, []u8, u8, usize, usize) bool' must be comptime-known, but operand value is runtime-known
52// :25:51: note: use '*const fn (*anyopaque, []u8, u8, usize, usize) bool' for a function pointer type
53// :25:51: error: values of type 'fn (*anyopaque, []u8, u8, usize) void' must be comptime-known, but operand value is runtime-known
54// :25:51: note: use '*const fn (*anyopaque, []u8, u8, usize) void' for a function pointer type
test/cases/compile_errors/error_note_for_function_parameter_incompatibility.zig+2-2
......@@ -12,6 +12,6 @@ export fn entry() void {
1212// backend=stage2
1313// target=native
1414//
15// :8:18: error: expected type '*const fn(i32) void', found '*const fn(bool) void'
16// :8:18: note: pointer type child 'fn(bool) void' cannot cast into pointer type child 'fn(i32) void'
15// :8:18: error: expected type '*const fn (i32) void', found '*const fn (bool) void'
16// :8:18: note: pointer type child 'fn (bool) void' cannot cast into pointer type child 'fn (i32) void'
1717// :8:18: note: parameter 0 'bool' cannot cast into 'i32'
test/cases/compile_errors/explain_why_fn_is_called_at_comptime.zig+1-1
......@@ -20,4 +20,4 @@ pub export fn entry() void {
2020// :12:13: note: argument to function being called at comptime must be comptime-known
2121// :7:25: note: expression is evaluated at comptime because the function returns a comptime-only type 'tmp.S'
2222// :2:12: note: struct requires comptime because of this field
23// :2:12: note: use '*const fn() void' for a function pointer type
23// :2:12: note: use '*const fn () void' for a function pointer type
test/cases/compile_errors/extern_function_pointer_mismatch.zig+1-1
......@@ -17,5 +17,5 @@ export fn entry() usize {
1717// backend=stage2
1818// target=native
1919//
20// :1:38: error: expected type 'fn(i32) i32', found 'fn(i32) callconv(.C) i32'
20// :1:38: error: expected type 'fn (i32) i32', found 'fn (i32) callconv(.C) i32'
2121// :1:38: note: calling convention 'C' cannot cast into calling convention 'Unspecified'
test/cases/compile_errors/file_level_struct_invalid_field_type.zig+1-1
......@@ -14,4 +14,4 @@ comptime {
1414// backend=stage2
1515// target=native
1616//
17// :7:15: error: expected type 'type', found 'fn() type'
17// :7:15: error: expected type 'type', found 'fn () type'
test/cases/compile_errors/function_type_coercion.zig+3-3
......@@ -13,9 +13,9 @@ export fn wrong_return_type() void {
1313// backend=stage2,llvm
1414// target=native
1515//
16// :3:25: error: expected type 'fn() void', found 'fn(i32) void'
16// :3:25: error: expected type 'fn () void', found 'fn (i32) void'
1717// :3:25: note: function with 1 parameters cannot cast into a function with 0 parameters
18// :6:28: error: expected type 'fn(f32) void', found 'fn(i32) void'
18// :6:28: error: expected type 'fn (f32) void', found 'fn (i32) void'
1919// :6:28: note: parameter 0 'i32' cannot cast into 'f32'
20// :9:24: error: expected type 'fn() i32', found 'fn(i32) void'
20// :9:24: error: expected type 'fn () i32', found 'fn (i32) void'
2121// :9:24: note: return type 'void' cannot cast into return type 'i32'
test/cases/compile_errors/invalid_array_elem_ty.zig+1-1
......@@ -9,4 +9,4 @@ pub export fn entry() void {
99// target=native
1010// backend=stage2
1111//
12// :5:12: error: expected type 'type', found 'fn() type'
12// :5:12: error: expected type 'type', found 'fn () type'
test/cases/compile_errors/invalid_comparison_for_function_pointers.zig+1-1
......@@ -9,4 +9,4 @@ export fn entry() usize {
99// backend=stage2
1010// target=native
1111//
12// :2:21: error: operator > not allowed for type 'fn() void'
12// :2:21: error: operator > not allowed for type 'fn () void'
test/cases/compile_errors/invalid_tail_call.zig+1-1
......@@ -9,4 +9,4 @@ pub export fn entry() void {
99// backend=llvm
1010// target=native
1111//
12// :5:5: error: unable to perform tail call: type of function being called 'fn(usize) void' does not match type of calling function 'fn() callconv(.C) void'
12// :5:5: error: unable to perform tail call: type of function being called 'fn (usize) void' does not match type of calling function 'fn () callconv(.C) void'
test/cases/compile_errors/nested_generic_function_param_type_mismatch.zig+2-2
......@@ -19,6 +19,6 @@ pub export fn entry() void {
1919// backend=llvm
2020// target=native
2121//
22// :15:28: error: expected type '*const fn(comptime type, u8, u8) u32', found '*const fn(void, u8, u8) u32'
23// :15:28: note: pointer type child 'fn(void, u8, u8) u32' cannot cast into pointer type child 'fn(comptime type, u8, u8) u32'
22// :15:28: error: expected type '*const fn (comptime type, u8, u8) u32', found '*const fn (void, u8, u8) u32'
23// :15:28: note: pointer type child 'fn (void, u8, u8) u32' cannot cast into pointer type child 'fn (comptime type, u8, u8) u32'
2424// :15:28: note: non-generic function cannot cast into a generic function
test/cases/compile_errors/noalias_param_coersion.zig+2-2
......@@ -14,7 +14,7 @@ fn bar(noalias _: *i32, _: *i32) void {}
1414// backend=stage2
1515// target=native
1616//
17// :3:9: error: expected type 'fn(noalias *i32, noalias *i32) void', found 'fn(noalias *i32, *i32) void'
17// :3:9: error: expected type 'fn (noalias *i32, noalias *i32) void', found 'fn (noalias *i32, *i32) void'
1818// :3:9: note: regular parameter 1 cannot cast into a noalias parameter
19// :7:9: error: expected type 'fn(*i32, *i32) void', found 'fn(noalias *i32, noalias *i32) void'
19// :7:9: error: expected type 'fn (*i32, *i32) void', found 'fn (noalias *i32, noalias *i32) void'
2020// :7:9: note: noalias parameter 0 cannot cast into a regular parameter
test/cases/compile_errors/non_comptime_param_in_comptime_function.zig+1-1
......@@ -31,6 +31,6 @@ export fn entry2() void {
3131// :1:6: note: param 'val' is required to be comptime
3232// :11:16: error: function with comptime-only return type 'tmp.S' requires all parameters to be comptime
3333// :9:10: note: struct requires comptime because of this field
34// :9:10: note: use '*const fn() void' for a function pointer type
34// :9:10: note: use '*const fn () void' for a function pointer type
3535// :11:8: note: param is required to be comptime
3636// :18:29: error: return type 'comptime_int' not allowed in function with calling convention 'C'
test/cases/compile_errors/old_fn_ptr_in_extern_context.zig+2-2
......@@ -12,9 +12,9 @@ comptime {
1212// backend=stage2
1313// target=native
1414//
15// :2:8: error: extern structs cannot contain fields of type 'fn() callconv(.C) void'
15// :2:8: error: extern structs cannot contain fields of type 'fn () callconv(.C) void'
1616// :2:8: note: type has no guaranteed in-memory representation
1717// :2:8: note: use '*const ' to make a function pointer type
18// :8:13: error: C pointers cannot point to non-C-ABI-compatible type '[4]fn() callconv(.C) void'
18// :8:13: error: C pointers cannot point to non-C-ABI-compatible type '[4]fn () callconv(.C) void'
1919// :8:13: note: type has no guaranteed in-memory representation
2020// :8:13: note: use '*const ' to make a function pointer type
test/cases/compile_errors/packed_struct_with_fields_of_not_allowed_types.zig+1-1
......@@ -84,7 +84,7 @@ export fn entry12() void {
8484// :59:18: note: union declared here
8585// :28:12: error: packed structs cannot contain fields of type '?anyerror'
8686// :28:12: note: type has no guaranteed in-memory representation
87// :38:12: error: packed structs cannot contain fields of type 'fn() void'
87// :38:12: error: packed structs cannot contain fields of type 'fn () void'
8888// :38:12: note: type has no guaranteed in-memory representation
8989// :38:12: note: use '*const ' to make a function pointer type
9090// :65:31: error: packed structs cannot contain fields of type '[]u8'
test/cases/compile_errors/passing_an_under-aligned_function_pointer.zig+1-1
......@@ -12,5 +12,5 @@ fn alignedSmall() align(4) i32 {
1212// backend=stage2
1313// target=x86_64-linux
1414//
15// :2:35: error: expected type '*const fn() align(8) i32', found '*const fn() align(4) i32'
15// :2:35: error: expected type '*const fn () align(8) i32', found '*const fn () align(4) i32'
1616// :2:35: note: pointer alignment '4' cannot cast into pointer alignment '8'
test/cases/compile_errors/runtime_indexing_comptime_array.zig+6-6
......@@ -24,9 +24,9 @@ pub export fn entry3() void {
2424// target=native
2525// backend=stage2
2626//
27// :7:10: error: values of type '[2]fn() void' must be comptime-known, but index value is runtime-known
28// :7:10: note: use '*const fn() void' for a function pointer type
29// :15:18: error: values of type '[2]fn() void' must be comptime-known, but index value is runtime-known
30// :15:17: note: use '*const fn() void' for a function pointer type
31// :21:19: error: values of type '[2]fn() void' must be comptime-known, but index value is runtime-known
32// :21:18: note: use '*const fn() void' for a function pointer type
27// :7:10: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
28// :7:10: note: use '*const fn () void' for a function pointer type
29// :15:18: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
30// :15:17: note: use '*const fn () void' for a function pointer type
31// :21:19: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
32// :21:18: note: use '*const fn () void' for a function pointer type
test/cases/compile_errors/self_referential_struct_requires_comptime.zig+1-1
......@@ -13,5 +13,5 @@ pub export fn entry() void {
1313//
1414// :6:12: error: variable of type 'tmp.S' must be const or comptime
1515// :2:8: note: struct requires comptime because of this field
16// :2:8: note: use '*const fn() void' for a function pointer type
16// :2:8: note: use '*const fn () void' for a function pointer type
1717// :3:8: note: struct requires comptime because of this field
test/cases/compile_errors/self_referential_union_requires_comptime.zig+1-1
......@@ -13,5 +13,5 @@ pub export fn entry() void {
1313//
1414// :6:12: error: variable of type 'tmp.U' must be const or comptime
1515// :2:8: note: union requires comptime because of this field
16// :2:8: note: use '*const fn() void' for a function pointer type
16// :2:8: note: use '*const fn () void' for a function pointer type
1717// :3:8: note: union requires comptime because of this field
test/cases/compile_errors/stage1/obj/generic_fn_as_parameter_without_comptime_keyword.zig+1-1
......@@ -8,4 +8,4 @@ export fn entry() void {
88// backend=stage1
99// target=native
1010//
11// tmp.zig:1:9: error: parameter of type 'fn(anytype) anytype' must be declared comptime
11// tmp.zig:1:9: error: parameter of type 'fn (anytype) anytype' must be declared comptime
test/cases/compile_errors/type_checking_function_pointers.zig+2-2
......@@ -12,6 +12,6 @@ export fn entry() void {
1212// backend=stage2
1313// target=native
1414//
15// :8:7: error: expected type '*const fn(*const u8) void', found '*const fn(u8) void'
16// :8:7: note: pointer type child 'fn(u8) void' cannot cast into pointer type child 'fn(*const u8) void'
15// :8:7: error: expected type '*const fn (*const u8) void', found '*const fn (u8) void'
16// :8:7: note: pointer type child 'fn (u8) void' cannot cast into pointer type child 'fn (*const u8) void'
1717// :8:7: note: parameter 0 'u8' cannot cast into '*const u8'
test/cases/compile_errors/type_mismatch_in_C_prototype_with_varargs.zig+1-1
......@@ -10,6 +10,6 @@ export fn main() void {
1010// backend=stage2
1111// target=native
1212//
13// :5:22: error: expected type '?fn([*c]u8, ...) callconv(.C) void', found 'fn([*:0]u8, ...) callconv(.C) void'
13// :5:22: error: expected type '?fn ([*c]u8, ...) callconv(.C) void', found 'fn ([*:0]u8, ...) callconv(.C) void'
1414// :5:22: note: parameter 0 '[*:0]u8' cannot cast into '[*c]u8'
1515// :5:22: note: '[*c]u8' could have null values which are illegal in type '[*:0]u8'
test/cases/compile_errors/wrong_function_type.zig+1-1
......@@ -16,5 +16,5 @@ export fn entry() usize {
1616// backend=stage2
1717// target=native
1818//
19// :1:28: error: expected type 'fn() void', found 'fn() i32'
19// :1:28: error: expected type 'fn () void', found 'fn () i32'
2020// :1:28: note: return type 'i32' cannot cast into return type 'void'
test/cases/compile_log.0.zig+1-1
......@@ -17,6 +17,6 @@ fn x() void {}
1717// :6:23: error: expected type 'usize', found 'bool'
1818//
1919// Compile Log Output:
20// @as(bool, true), @as(comptime_int, 20), @as(u32, [runtime value]), @as(fn() void, (function 'x'))
20// @as(bool, true), @as(comptime_int, 20), @as(u32, [runtime value]), @as(fn () void, (function 'x'))
2121// @as(comptime_int, 1000)
2222// @as(comptime_int, 1234)
test/cases/compile_log.1.zig+1-1
......@@ -16,5 +16,5 @@ fn x() void {}
1616// :4:5: note: also here
1717//
1818// Compile Log Output:
19// @as(bool, true), @as(comptime_int, 20), @as(u32, [runtime value]), @as(fn() void, (function 'x'))
19// @as(bool, true), @as(comptime_int, 20), @as(u32, [runtime value]), @as(fn () void, (function 'x'))
2020// @as(comptime_int, 1000)