| author | |
| committer | |
| log | ee4ced96833470f9432e6a5dc5b31534457280c0 |
| tree | 8d35dc654895f029e23ce710367b839814ed5cd9 |
| parent | 3e79315d19c7dfe5f9b90185d8030209ef8dd829 |
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 { |
| 21 | 21 | /// ``` |
| 22 | 22 | /// const RefCount = struct { |
| 23 | 23 | /// count: Atomic(usize), |
| 24 | /// dropFn: *const fn(*RefCount) void, | |
| 24 | /// dropFn: *const fn (*RefCount) void, | |
| 25 | 25 | /// |
| 26 | 26 | /// fn ref(self: *RefCount) void { |
| 27 | 27 | /// _ = 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 { |
| 1269 | 1269 | if (@TypeOf(T.Key) != type) @compileError("Indexer.Key must be a type."); |
| 1270 | 1270 | if (!@hasDecl(T, "count")) @compileError("Indexer must have decl count: usize."); |
| 1271 | 1271 | 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."); | |
| 1276 | 1276 | } |
| 1277 | 1277 | } |
| 1278 | 1278 |
lib/std/fmt.zig+2-2| ... | ... | @@ -2255,11 +2255,11 @@ test "pointer" { |
| 2255 | 2255 | const FnPtr = *align(1) const fn () void; |
| 2256 | 2256 | { |
| 2257 | 2257 | 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}); | |
| 2259 | 2259 | } |
| 2260 | 2260 | { |
| 2261 | 2261 | 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}); | |
| 2263 | 2263 | } |
| 2264 | 2264 | } |
| 2265 | 2265 |
lib/std/meta.zig+3-3| ... | ... | @@ -969,9 +969,9 @@ test "std.meta.Float" { |
| 969 | 969 | /// correspond to the argument types. |
| 970 | 970 | /// |
| 971 | 971 | /// 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 }` | |
| 975 | 975 | pub fn ArgsTuple(comptime Function: type) type { |
| 976 | 976 | const info = @typeInfo(Function); |
| 977 | 977 | if (info != .Fn) |
lib/std/treap.zig+1-1| ... | ... | @@ -7,7 +7,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type { |
| 7 | 7 | return struct { |
| 8 | 8 | const Self = @This(); |
| 9 | 9 | |
| 10 | // Allow for compareFn to be fn(anytype, anytype) anytype | |
| 10 | // Allow for compareFn to be fn (anytype, anytype) anytype | |
| 11 | 11 | // which allows the convenient use of std.math.order. |
| 12 | 12 | fn compare(a: Key, b: Key) Order { |
| 13 | 13 | return compareFn(a, b); |
lib/std/zig/Ast.zig+4-4| ... | ... | @@ -3255,23 +3255,23 @@ pub const Node = struct { |
| 3255 | 3255 | @"break", |
| 3256 | 3256 | /// `return lhs`. lhs can be omitted. rhs is unused. |
| 3257 | 3257 | @"return", |
| 3258 | /// `fn(a: lhs) rhs`. lhs can be omitted. | |
| 3258 | /// `fn (a: lhs) rhs`. lhs can be omitted. | |
| 3259 | 3259 | /// anytype and ... parameters are omitted from the AST tree. |
| 3260 | 3260 | /// main_token is the `fn` keyword. |
| 3261 | 3261 | /// extern function declarations use this tag. |
| 3262 | 3262 | 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]`. | |
| 3264 | 3264 | /// anytype and ... parameters are omitted from the AST tree. |
| 3265 | 3265 | /// main_token is the `fn` keyword. |
| 3266 | 3266 | /// extern function declarations use this tag. |
| 3267 | 3267 | 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]`. | |
| 3269 | 3269 | /// zero or one parameters. |
| 3270 | 3270 | /// anytype and ... parameters are omitted from the AST tree. |
| 3271 | 3271 | /// main_token is the `fn` keyword. |
| 3272 | 3272 | /// extern function declarations use this tag. |
| 3273 | 3273 | 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]`. | |
| 3275 | 3275 | /// anytype and ... parameters are omitted from the AST tree. |
| 3276 | 3276 | /// main_token is the `fn` keyword. |
| 3277 | 3277 | /// 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" { |
| 5251 | 5251 | \\ } |
| 5252 | 5252 | \\} |
| 5253 | 5253 | \\ |
| 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; | |
| 5256 | 5256 | \\ |
| 5257 | 5257 | \\fn fn_calls() void { |
| 5258 | 5258 | \\ fn add(x: i32, y: i32,) i32 { x + y }; |
src/Sema.zig+1-1| ... | ... | @@ -6722,7 +6722,7 @@ fn zirCall( |
| 6722 | 6722 | { |
| 6723 | 6723 | const return_ty = sema.typeOf(call_inst); |
| 6724 | 6724 | 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 | |
| 6726 | 6726 | |
| 6727 | 6727 | // TODO: we don't fix up the error trace for always_tail correctly, we should be doing it |
| 6728 | 6728 | // *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 { |
| 364 | 364 | if (fn_info.is_noinline) { |
| 365 | 365 | try writer.writeAll("noinline "); |
| 366 | 366 | } |
| 367 | try writer.writeAll("fn("); | |
| 367 | try writer.writeAll("fn ("); | |
| 368 | 368 | const param_types = fn_info.param_types.get(&mod.intern_pool); |
| 369 | 369 | for (param_types, 0..) |param_ty, i| { |
| 370 | 370 | if (i != 0) try writer.writeAll(", "); |
test/behavior/cast.zig+1-1| ... | ... | @@ -1194,7 +1194,7 @@ test "implicit ptr to *anyopaque" { |
| 1194 | 1194 | try expect(c.* == 1); |
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | test "return null from fn() anyerror!?&T" { | |
| 1197 | test "return null from fn () anyerror!?&T" { | |
| 1198 | 1198 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 1199 | 1199 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 1200 | 1200 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; |
test/behavior/typename.zig+16-16| ... | ... | @@ -73,18 +73,18 @@ test "basic" { |
| 73 | 73 | try expectEqualStrings("*usize", @typeName(*usize)); |
| 74 | 74 | try expectEqualStrings("[]u8", @typeName([]u8)); |
| 75 | 75 | |
| 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)); | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | test "top level decl" { |
| ... | ... | @@ -108,17 +108,17 @@ test "top level decl" { |
| 108 | 108 | |
| 109 | 109 | // regular fn, without error |
| 110 | 110 | try expectEqualStrings( |
| 111 | "fn() void", | |
| 111 | "fn () void", | |
| 112 | 112 | @typeName(@TypeOf(regular)), |
| 113 | 113 | ); |
| 114 | 114 | // regular fn inside struct, with error |
| 115 | 115 | 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", | |
| 117 | 117 | @typeName(@TypeOf(B.doTest)), |
| 118 | 118 | ); |
| 119 | 119 | // generic fn |
| 120 | 120 | try expectEqualStrings( |
| 121 | "fn(comptime type) type", | |
| 121 | "fn (comptime type) type", | |
| 122 | 122 | @typeName(@TypeOf(TypeFromFn)), |
| 123 | 123 | ); |
| 124 | 124 | } |
| ... | ... | @@ -234,7 +234,7 @@ test "comptime parameters not converted to anytype in function type" { |
| 234 | 234 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; |
| 235 | 235 | |
| 236 | 236 | 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)); | |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | test "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 { |
| 16 | 16 | // :8:12: error: variable of type 'tmp.S1' must be const or comptime |
| 17 | 17 | // :2:8: note: struct requires comptime because of this field |
| 18 | 18 | // :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 {} |
| 8 | 8 | // backend=stage2 |
| 9 | 9 | // target=native |
| 10 | 10 | // |
| 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 | |
| 12 | 12 | // :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 {} |
| 9 | 9 | // backend=stage1 |
| 10 | 10 | // target=native |
| 11 | 11 | // |
| 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 { |
| 11 | 11 | // backend=stage2 |
| 12 | 12 | // target=native |
| 13 | 13 | // |
| 14 | // :3:9: error: cannot call optional type '?fn() void' | |
| 14 | // :3:9: error: cannot call optional type '?fn () void' | |
| 15 | 15 | // :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' | |
| 17 | 17 | // :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 { |
| 17 | 17 | // backend=stage2 |
| 18 | 18 | // target=native |
| 19 | 19 | // |
| 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' | |
| 22 | 22 | // :6:9: note: parameter 0 'u64' cannot cast into 'i8' |
| 23 | 23 | // :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' | |
| 26 | 26 | // :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 {} |
| 14 | 14 | // backend=stage2 |
| 15 | 15 | // target=native |
| 16 | 16 | // |
| 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' | |
| 18 | 18 | // :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' | |
| 20 | 20 | // :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 { |
| 20 | 20 | // backend=stage2 |
| 21 | 21 | // target=native |
| 22 | 22 | // |
| 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 | |
| 24 | 24 | // :3:6: note: function is generic |
| 25 | 25 | // :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 { |
| 40 | 40 | // :8:9: note: condition in comptime branch must be comptime-known |
| 41 | 41 | // :7:13: note: expression is evaluated at comptime because the function returns a comptime-only type 'tmp.S' |
| 42 | 42 | // :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 | |
| 44 | 44 | // :19:15: note: called from here |
| 45 | 45 | // :22:13: error: unable to resolve comptime value |
| 46 | 46 | // :22:13: note: condition in comptime switch must be comptime-known |
| 47 | 47 | // :21:17: note: expression is evaluated at comptime because the function returns a comptime-only type 'tmp.S' |
| 48 | 48 | // :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 | |
| 50 | 50 | // :32:19: note: called from here |
test/cases/compile_errors/dereference_anyopaque.zig+6-6| ... | ... | @@ -46,9 +46,9 @@ pub export fn entry() void { |
| 46 | 46 | // |
| 47 | 47 | // :11:22: error: comparison of 'void' with null |
| 48 | 48 | // :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 { |
| 12 | 12 | // backend=stage2 |
| 13 | 13 | // target=native |
| 14 | 14 | // |
| 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' | |
| 17 | 17 | // :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 { |
| 20 | 20 | // :12:13: note: argument to function being called at comptime must be comptime-known |
| 21 | 21 | // :7:25: note: expression is evaluated at comptime because the function returns a comptime-only type 'tmp.S' |
| 22 | 22 | // :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 { |
| 17 | 17 | // backend=stage2 |
| 18 | 18 | // target=native |
| 19 | 19 | // |
| 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' | |
| 21 | 21 | // :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 { |
| 14 | 14 | // backend=stage2 |
| 15 | 15 | // target=native |
| 16 | 16 | // |
| 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 { |
| 13 | 13 | // backend=stage2,llvm |
| 14 | 14 | // target=native |
| 15 | 15 | // |
| 16 | // :3:25: error: expected type 'fn() void', found 'fn(i32) void' | |
| 16 | // :3:25: error: expected type 'fn () void', found 'fn (i32) void' | |
| 17 | 17 | // :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' | |
| 19 | 19 | // :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' | |
| 21 | 21 | // :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 { |
| 9 | 9 | // target=native |
| 10 | 10 | // backend=stage2 |
| 11 | 11 | // |
| 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 { |
| 9 | 9 | // backend=stage2 |
| 10 | 10 | // target=native |
| 11 | 11 | // |
| 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 { |
| 9 | 9 | // backend=llvm |
| 10 | 10 | // target=native |
| 11 | 11 | // |
| 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 { |
| 19 | 19 | // backend=llvm |
| 20 | 20 | // target=native |
| 21 | 21 | // |
| 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' | |
| 24 | 24 | // :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 {} |
| 14 | 14 | // backend=stage2 |
| 15 | 15 | // target=native |
| 16 | 16 | // |
| 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' | |
| 18 | 18 | // :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' | |
| 20 | 20 | // :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 { |
| 31 | 31 | // :1:6: note: param 'val' is required to be comptime |
| 32 | 32 | // :11:16: error: function with comptime-only return type 'tmp.S' requires all parameters to be comptime |
| 33 | 33 | // :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 | |
| 35 | 35 | // :11:8: note: param is required to be comptime |
| 36 | 36 | // :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 { |
| 12 | 12 | // backend=stage2 |
| 13 | 13 | // target=native |
| 14 | 14 | // |
| 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' | |
| 16 | 16 | // :2:8: note: type has no guaranteed in-memory representation |
| 17 | 17 | // :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' | |
| 19 | 19 | // :8:13: note: type has no guaranteed in-memory representation |
| 20 | 20 | // :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 { |
| 84 | 84 | // :59:18: note: union declared here |
| 85 | 85 | // :28:12: error: packed structs cannot contain fields of type '?anyerror' |
| 86 | 86 | // :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' | |
| 88 | 88 | // :38:12: note: type has no guaranteed in-memory representation |
| 89 | 89 | // :38:12: note: use '*const ' to make a function pointer type |
| 90 | 90 | // :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 { |
| 12 | 12 | // backend=stage2 |
| 13 | 13 | // target=x86_64-linux |
| 14 | 14 | // |
| 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' | |
| 16 | 16 | // :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 { |
| 24 | 24 | // target=native |
| 25 | 25 | // backend=stage2 |
| 26 | 26 | // |
| 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 { |
| 13 | 13 | // |
| 14 | 14 | // :6:12: error: variable of type 'tmp.S' must be const or comptime |
| 15 | 15 | // :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 | |
| 17 | 17 | // :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 { |
| 13 | 13 | // |
| 14 | 14 | // :6:12: error: variable of type 'tmp.U' must be const or comptime |
| 15 | 15 | // :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 | |
| 17 | 17 | // :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 { |
| 8 | 8 | // backend=stage1 |
| 9 | 9 | // target=native |
| 10 | 10 | // |
| 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 { |
| 12 | 12 | // backend=stage2 |
| 13 | 13 | // target=native |
| 14 | 14 | // |
| 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' | |
| 17 | 17 | // :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 { |
| 10 | 10 | // backend=stage2 |
| 11 | 11 | // target=native |
| 12 | 12 | // |
| 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' | |
| 14 | 14 | // :5:22: note: parameter 0 '[*:0]u8' cannot cast into '[*c]u8' |
| 15 | 15 | // :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 { |
| 16 | 16 | // backend=stage2 |
| 17 | 17 | // target=native |
| 18 | 18 | // |
| 19 | // :1:28: error: expected type 'fn() void', found 'fn() i32' | |
| 19 | // :1:28: error: expected type 'fn () void', found 'fn () i32' | |
| 20 | 20 | // :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 {} |
| 17 | 17 | // :6:23: error: expected type 'usize', found 'bool' |
| 18 | 18 | // |
| 19 | 19 | // 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')) | |
| 21 | 21 | // @as(comptime_int, 1000) |
| 22 | 22 | // @as(comptime_int, 1234) |
test/cases/compile_log.1.zig+1-1| ... | ... | @@ -16,5 +16,5 @@ fn x() void {} |
| 16 | 16 | // :4:5: note: also here |
| 17 | 17 | // |
| 18 | 18 | // 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')) | |
| 20 | 20 | // @as(comptime_int, 1000) |