authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-12-08 19:52:05+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-09 20:37:18-07:00
log9d93b2ccf11f584320a2c5209dd2d94705167695
treebc746509f92c029be2b6cd3338aace01a5baa91e
parent5831b68341827b544ea3f268c921e9044bd11047

Eliminate `BoundFn` type from the language

Closes #9484

23 files changed, 3 insertions(+), 52 deletions(-)

doc/langref.html.in+1-6
......@@ -9366,12 +9366,7 @@ test "integer truncation" {
93669366 <li>{#link|union#}</li>
93679367 </ul>
93689368 <p>
9369 For these types, {#syntax#}@Type{#endsyntax#} is not available:
9370 </p>
9371 <ul>
9372 <li>{#link|Functions#}</li>
9373 <li>BoundFn</li>
9374 </ul>
9369 {#syntax#}@Type{#endsyntax#} is not available for {#link|Functions#}.
93759370 {#header_close#}
93769371 {#header_open|@typeInfo#}
93779372 <pre>{#syntax#}@typeInfo(comptime T: type) std.builtin.Type{#endsyntax#}</pre>
lib/std/builtin.zig-1
......@@ -210,7 +210,6 @@ pub const Type = union(enum) {
210210 Enum: Enum,
211211 Union: Union,
212212 Fn: Fn,
213 BoundFn: Fn,
214213 Opaque: Opaque,
215214 Frame: Frame,
216215 AnyFrame: AnyFrame,
lib/std/hash/auto_hash.zig+1-1
......@@ -101,7 +101,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
101101 .Bool => hash(hasher, @boolToInt(key), strat),
102102 .Enum => hash(hasher, @enumToInt(key), strat),
103103 .ErrorSet => hash(hasher, @errorToInt(key), strat),
104 .AnyFrame, .BoundFn, .Fn => hash(hasher, @ptrToInt(key), strat),
104 .AnyFrame, .Fn => hash(hasher, @ptrToInt(key), strat),
105105
106106 .Pointer => @call(.{ .modifier = .always_inline }, hashPointer, .{ hasher, key, strat }),
107107
lib/std/mem.zig-1
......@@ -308,7 +308,6 @@ pub fn zeroes(comptime T: type) T {
308308 .ErrorUnion,
309309 .ErrorSet,
310310 .Fn,
311 .BoundFn,
312311 .Type,
313312 .NoReturn,
314313 .Undefined,
lib/std/meta/trait.zig-1
......@@ -549,7 +549,6 @@ pub fn hasUniqueRepresentation(comptime T: type) bool {
549549 else => return false, // TODO can we know if it's true for some of these types ?
550550
551551 .AnyFrame,
552 .BoundFn,
553552 .Enum,
554553 .ErrorSet,
555554 .Fn,
lib/std/testing.zig-1
......@@ -46,7 +46,6 @@ pub fn expectError(expected_error: anyerror, actual_error_union: anytype) !void
4646pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) !void {
4747 switch (@typeInfo(@TypeOf(actual))) {
4848 .NoReturn,
49 .BoundFn,
5049 .Opaque,
5150 .Frame,
5251 .AnyFrame,
src/Autodoc.zig-1
......@@ -607,7 +607,6 @@ const DocData = struct {
607607 is_test: bool = false,
608608 is_extern: bool = false,
609609 },
610 BoundFn: struct { name: []const u8 },
611610 Opaque: struct {
612611 name: []const u8,
613612 src: usize, // index into astNodes
src/Sema.zig-14
......@@ -9275,7 +9275,6 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
92759275 dest_ty.fmt(sema.mod), container,
92769276 });
92779277 },
9278 .BoundFn => @panic("TODO remove this type from the language and compiler"),
92799278
92809279 .Array,
92819280 .Bool,
......@@ -9339,7 +9338,6 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
93399338 operand_ty.fmt(sema.mod), container,
93409339 });
93419340 },
9342 .BoundFn => @panic("TODO remove this type from the language and compiler"),
93439341
93449342 .Array,
93459343 .Bool,
......@@ -9777,7 +9775,6 @@ fn zirSwitchCond(
97779775 .Undefined,
97789776 .Null,
97799777 .Optional,
9780 .BoundFn,
97819778 .Opaque,
97829779 .Vector,
97839780 .Frame,
......@@ -10361,7 +10358,6 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1036110358 .Undefined,
1036210359 .Null,
1036310360 .Optional,
10364 .BoundFn,
1036510361 .Opaque,
1036610362 .Vector,
1036710363 .Frame,
......@@ -14833,7 +14829,6 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1483314829 .NoReturn,
1483414830 .Undefined,
1483514831 .Null,
14836 .BoundFn,
1483714832 .Opaque,
1483814833 => return sema.fail(block, operand_src, "no size available for type '{}'", .{ty.fmt(sema.mod)}),
1483914834
......@@ -14877,7 +14872,6 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
1487714872 .NoReturn,
1487814873 .Undefined,
1487914874 .Null,
14880 .BoundFn,
1488114875 .Opaque,
1488214876 => return sema.fail(block, operand_src, "no size available for type '{}'", .{operand_ty.fmt(sema.mod)}),
1488314877
......@@ -15908,7 +15902,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1590815902 }),
1590915903 );
1591015904 },
15911 .BoundFn => @panic("TODO remove this type from the language and compiler"),
1591215905 .Frame => return sema.failWithUseOfAsync(block, src),
1591315906 .AnyFrame => return sema.failWithUseOfAsync(block, src),
1591415907 }
......@@ -18609,7 +18602,6 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in
1860918602 const ty = try Type.Tag.function.create(sema.arena, fn_info);
1861018603 return sema.addType(ty);
1861118604 },
18612 .BoundFn => @panic("TODO delete BoundFn from the language"),
1861318605 .Frame => return sema.failWithUseOfAsync(block, src),
1861418606 }
1861518607}
......@@ -21790,7 +21782,6 @@ fn validateRunTimeType(
2179021782
2179121783 .Enum => return !(try sema.typeRequiresComptime(ty)),
2179221784
21793 .BoundFn,
2179421785 .ComptimeFloat,
2179521786 .ComptimeInt,
2179621787 .EnumLiteral,
......@@ -21876,7 +21867,6 @@ fn explainWhyTypeIsComptimeInner(
2187621867 try mod.errNoteNonLazy(src_loc, msg, "types are not available at runtime", .{});
2187721868 },
2187821869
21879 .BoundFn,
2188021870 .ComptimeFloat,
2188121871 .ComptimeInt,
2188221872 .EnumLiteral,
......@@ -21986,7 +21976,6 @@ fn validateExternType(
2198621976 .Null,
2198721977 .ErrorUnion,
2198821978 .ErrorSet,
21989 .BoundFn,
2199021979 .Frame,
2199121980 => return false,
2199221981 .Void => return position == .union_field or position == .ret_ty,
......@@ -22058,7 +22047,6 @@ fn explainWhyTypeIsNotExtern(
2205822047 .Null,
2205922048 .ErrorUnion,
2206022049 .ErrorSet,
22061 .BoundFn,
2206222050 .Frame,
2206322051 => return,
2206422052
......@@ -22116,7 +22104,6 @@ fn validatePackedType(ty: Type) bool {
2211622104 .Null,
2211722105 .ErrorUnion,
2211822106 .ErrorSet,
22119 .BoundFn,
2212022107 .Frame,
2212122108 .NoReturn,
2212222109 .Opaque,
......@@ -22158,7 +22145,6 @@ fn explainWhyTypeIsNotPacked(
2215822145 .EnumLiteral,
2215922146 .Undefined,
2216022147 .Null,
22161 .BoundFn,
2216222148 .Frame,
2216322149 .NoReturn,
2216422150 .Opaque,
src/arch/aarch64/CodeGen.zig-1
......@@ -6200,7 +6200,6 @@ fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {
62006200 .NoReturn => unreachable,
62016201 .Undefined => unreachable,
62026202 .Null => unreachable,
6203 .BoundFn => unreachable,
62046203 .Opaque => unreachable,
62056204
62066205 else => {},
src/arch/aarch64/abi.zig-1
......@@ -64,7 +64,6 @@ pub fn classifyType(ty: Type, target: std.Target) Class {
6464 .ComptimeInt,
6565 .Undefined,
6666 .Null,
67 .BoundFn,
6867 .Fn,
6968 .Opaque,
7069 .EnumLiteral,
src/arch/arm/CodeGen.zig-1
......@@ -6156,7 +6156,6 @@ fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {
61566156 .NoReturn => unreachable,
61576157 .Undefined => unreachable,
61586158 .Null => unreachable,
6159 .BoundFn => unreachable,
61606159 .Opaque => unreachable,
61616160
61626161 else => {},
src/arch/arm/abi.zig-1
......@@ -105,7 +105,6 @@ pub fn classifyType(ty: Type, target: std.Target, ctx: Context) Class {
105105 .ComptimeInt,
106106 .Undefined,
107107 .Null,
108 .BoundFn,
109108 .Fn,
110109 .Opaque,
111110 .EnumLiteral,
src/arch/riscv64/abi.zig-1
......@@ -63,7 +63,6 @@ pub fn classifyType(ty: Type, target: std.Target) Class {
6363 .ComptimeInt,
6464 .Undefined,
6565 .Null,
66 .BoundFn,
6766 .Fn,
6867 .Opaque,
6968 .EnumLiteral,
src/arch/wasm/CodeGen.zig-1
......@@ -1599,7 +1599,6 @@ fn isByRef(ty: Type, target: std.Target) bool {
15991599 .EnumLiteral,
16001600 .Undefined,
16011601 .Null,
1602 .BoundFn,
16031602 .Opaque,
16041603 => unreachable,
16051604
src/arch/wasm/abi.zig-1
......@@ -80,7 +80,6 @@ pub fn classifyType(ty: Type, target: Target) [2]Class {
8080 .ComptimeInt,
8181 .Undefined,
8282 .Null,
83 .BoundFn,
8483 .Fn,
8584 .Opaque,
8685 .EnumLiteral,
src/arch/x86_64/CodeGen.zig-1
......@@ -6942,7 +6942,6 @@ fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {
69426942 .NoReturn => unreachable,
69436943 .Undefined => unreachable,
69446944 .Null => unreachable,
6945 .BoundFn => unreachable,
69466945 .Opaque => unreachable,
69476946
69486947 else => {},
src/arch/x86_64/abi.zig-1
......@@ -52,7 +52,6 @@ pub fn classifyWindows(ty: Type, target: Target) Class {
5252 .ComptimeInt,
5353 .Undefined,
5454 .Null,
55 .BoundFn,
5655 .Fn,
5756 .Opaque,
5857 .EnumLiteral,
src/codegen/c.zig-4
......@@ -866,7 +866,6 @@ pub const DeclGen = struct {
866866 .NoReturn,
867867 .Undefined,
868868 .Null,
869 .BoundFn,
870869 .Opaque,
871870 => unreachable,
872871
......@@ -1320,7 +1319,6 @@ pub const DeclGen = struct {
13201319 .NoReturn => unreachable,
13211320 .Undefined => unreachable,
13221321 .Null => unreachable,
1323 .BoundFn => unreachable,
13241322 .Opaque => unreachable,
13251323
13261324 .Frame,
......@@ -2050,8 +2048,6 @@ pub const DeclGen = struct {
20502048 .ComptimeInt,
20512049 .Type,
20522050 => unreachable, // must be const or comptime
2053
2054 .BoundFn => unreachable, // this type will be deleted from the language
20552051 }
20562052 }
20572053
src/codegen/llvm.zig-6
......@@ -2341,8 +2341,6 @@ pub const Object = struct {
23412341 .Null => unreachable,
23422342 .EnumLiteral => unreachable,
23432343
2344 .BoundFn => @panic("TODO remove BoundFn from the language"),
2345
23462344 .Frame => @panic("TODO implement lowerDebugType for Frame types"),
23472345 .AnyFrame => @panic("TODO implement lowerDebugType for AnyFrame types"),
23482346 }
......@@ -3095,8 +3093,6 @@ pub const DeclGen = struct {
30953093 .Null => unreachable,
30963094 .EnumLiteral => unreachable,
30973095
3098 .BoundFn => @panic("TODO remove BoundFn from the language"),
3099
31003096 .Frame => @panic("TODO implement llvmType for Frame types"),
31013097 .AnyFrame => @panic("TODO implement llvmType for AnyFrame types"),
31023098 }
......@@ -3896,7 +3892,6 @@ pub const DeclGen = struct {
38963892 .NoReturn => unreachable,
38973893 .Undefined => unreachable,
38983894 .Null => unreachable,
3899 .BoundFn => unreachable,
39003895 .Opaque => unreachable,
39013896
39023897 .Frame,
......@@ -10792,7 +10787,6 @@ fn isByRef(ty: Type) bool {
1079210787 .EnumLiteral,
1079310788 .Undefined,
1079410789 .Null,
10795 .BoundFn,
1079610790 .Opaque,
1079710791 => unreachable,
1079810792
src/codegen/spirv.zig-2
......@@ -538,8 +538,6 @@ pub const DeclGen = struct {
538538 .Type,
539539 => unreachable, // Must be comptime.
540540
541 .BoundFn => unreachable, // this type will be deleted from the language.
542
543541 else => |tag| return self.todo("Implement zig type '{}'", .{tag}),
544542 };
545543 }
src/type.zig-2
......@@ -185,7 +185,6 @@ pub const Type = extern union {
185185 .Void,
186186 .ErrorSet,
187187 .Fn,
188 .BoundFn,
189188 .Opaque,
190189 .AnyFrame,
191190 .Enum,
......@@ -4074,7 +4073,6 @@ pub const Type = extern union {
40744073 => return true,
40754074
40764075 .Opaque => return is_extern,
4077 .BoundFn,
40784076 .ComptimeFloat,
40794077 .ComptimeInt,
40804078 .EnumLiteral,
src/value.zig-2
......@@ -2419,7 +2419,6 @@ pub const Value = extern union {
24192419 if (val.tag() == .runtime_value) return;
24202420
24212421 switch (zig_ty_tag) {
2422 .BoundFn => unreachable, // TODO remove this from the language
24232422 .Opaque => unreachable, // Cannot hash opaque types
24242423
24252424 .Void,
......@@ -2566,7 +2565,6 @@ pub const Value = extern union {
25662565 if (val.tag() == .runtime_value) return;
25672566
25682567 switch (ty.zigTypeTag()) {
2569 .BoundFn => unreachable, // TODO remove this from the language
25702568 .Opaque => unreachable, // Cannot hash opaque types
25712569 .Void,
25722570 .NoReturn,
test/behavior/type_info.zig+1-1
......@@ -252,7 +252,7 @@ fn testUnion() !void {
252252 try expect(typeinfo_info == .Union);
253253 try expect(typeinfo_info.Union.layout == .Auto);
254254 try expect(typeinfo_info.Union.tag_type.? == TypeId);
255 try expect(typeinfo_info.Union.fields.len == 25);
255 try expect(typeinfo_info.Union.fields.len == 24);
256256 try expect(typeinfo_info.Union.fields[4].field_type == @TypeOf(@typeInfo(u8).Int));
257257 try expect(typeinfo_info.Union.decls.len == 22);
258258