Commit 9d93b2ccf1

Veikka Tuominen <git@vexu.eu>
2022-12-08 18:52:05
Eliminate `BoundFn` type from the language
Closes #9484
1 parent 5831b68
doc/langref.html.in
@@ -9366,12 +9366,7 @@ test "integer truncation" {
           <li>{#link|union#}</li>
       </ul>
       <p>
-      For these types, {#syntax#}@Type{#endsyntax#} is not available:
-      </p>
-      <ul>
-          <li>{#link|Functions#}</li>
-          <li>BoundFn</li>
-      </ul>
+      {#syntax#}@Type{#endsyntax#} is not available for {#link|Functions#}.
       {#header_close#}
       {#header_open|@typeInfo#}
       <pre>{#syntax#}@typeInfo(comptime T: type) std.builtin.Type{#endsyntax#}</pre>
lib/std/hash/auto_hash.zig
@@ -101,7 +101,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
         .Bool => hash(hasher, @boolToInt(key), strat),
         .Enum => hash(hasher, @enumToInt(key), strat),
         .ErrorSet => hash(hasher, @errorToInt(key), strat),
-        .AnyFrame, .BoundFn, .Fn => hash(hasher, @ptrToInt(key), strat),
+        .AnyFrame, .Fn => hash(hasher, @ptrToInt(key), strat),
 
         .Pointer => @call(.{ .modifier = .always_inline }, hashPointer, .{ hasher, key, strat }),
 
lib/std/meta/trait.zig
@@ -549,7 +549,6 @@ pub fn hasUniqueRepresentation(comptime T: type) bool {
         else => return false, // TODO can we know if it's true for some of these types ?
 
         .AnyFrame,
-        .BoundFn,
         .Enum,
         .ErrorSet,
         .Fn,
lib/std/builtin.zig
@@ -210,7 +210,6 @@ pub const Type = union(enum) {
     Enum: Enum,
     Union: Union,
     Fn: Fn,
-    BoundFn: Fn,
     Opaque: Opaque,
     Frame: Frame,
     AnyFrame: AnyFrame,
lib/std/mem.zig
@@ -308,7 +308,6 @@ pub fn zeroes(comptime T: type) T {
         .ErrorUnion,
         .ErrorSet,
         .Fn,
-        .BoundFn,
         .Type,
         .NoReturn,
         .Undefined,
lib/std/testing.zig
@@ -46,7 +46,6 @@ pub fn expectError(expected_error: anyerror, actual_error_union: anytype) !void
 pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) !void {
     switch (@typeInfo(@TypeOf(actual))) {
         .NoReturn,
-        .BoundFn,
         .Opaque,
         .Frame,
         .AnyFrame,
src/arch/aarch64/abi.zig
@@ -64,7 +64,6 @@ pub fn classifyType(ty: Type, target: std.Target) Class {
         .ComptimeInt,
         .Undefined,
         .Null,
-        .BoundFn,
         .Fn,
         .Opaque,
         .EnumLiteral,
src/arch/aarch64/CodeGen.zig
@@ -6200,7 +6200,6 @@ fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {
         .NoReturn => unreachable,
         .Undefined => unreachable,
         .Null => unreachable,
-        .BoundFn => unreachable,
         .Opaque => unreachable,
 
         else => {},
src/arch/arm/abi.zig
@@ -105,7 +105,6 @@ pub fn classifyType(ty: Type, target: std.Target, ctx: Context) Class {
         .ComptimeInt,
         .Undefined,
         .Null,
-        .BoundFn,
         .Fn,
         .Opaque,
         .EnumLiteral,
src/arch/arm/CodeGen.zig
@@ -6156,7 +6156,6 @@ fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {
         .NoReturn => unreachable,
         .Undefined => unreachable,
         .Null => unreachable,
-        .BoundFn => unreachable,
         .Opaque => unreachable,
 
         else => {},
src/arch/riscv64/abi.zig
@@ -63,7 +63,6 @@ pub fn classifyType(ty: Type, target: std.Target) Class {
         .ComptimeInt,
         .Undefined,
         .Null,
-        .BoundFn,
         .Fn,
         .Opaque,
         .EnumLiteral,
src/arch/wasm/abi.zig
@@ -80,7 +80,6 @@ pub fn classifyType(ty: Type, target: Target) [2]Class {
         .ComptimeInt,
         .Undefined,
         .Null,
-        .BoundFn,
         .Fn,
         .Opaque,
         .EnumLiteral,
src/arch/wasm/CodeGen.zig
@@ -1599,7 +1599,6 @@ fn isByRef(ty: Type, target: std.Target) bool {
         .EnumLiteral,
         .Undefined,
         .Null,
-        .BoundFn,
         .Opaque,
         => unreachable,
 
src/arch/x86_64/abi.zig
@@ -52,7 +52,6 @@ pub fn classifyWindows(ty: Type, target: Target) Class {
         .ComptimeInt,
         .Undefined,
         .Null,
-        .BoundFn,
         .Fn,
         .Opaque,
         .EnumLiteral,
src/arch/x86_64/CodeGen.zig
@@ -6942,7 +6942,6 @@ fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {
         .NoReturn => unreachable,
         .Undefined => unreachable,
         .Null => unreachable,
-        .BoundFn => unreachable,
         .Opaque => unreachable,
 
         else => {},
src/codegen/c.zig
@@ -866,7 +866,6 @@ pub const DeclGen = struct {
                 .NoReturn,
                 .Undefined,
                 .Null,
-                .BoundFn,
                 .Opaque,
                 => unreachable,
 
@@ -1320,7 +1319,6 @@ pub const DeclGen = struct {
             .NoReturn => unreachable,
             .Undefined => unreachable,
             .Null => unreachable,
-            .BoundFn => unreachable,
             .Opaque => unreachable,
 
             .Frame,
@@ -2050,8 +2048,6 @@ pub const DeclGen = struct {
             .ComptimeInt,
             .Type,
             => unreachable, // must be const or comptime
-
-            .BoundFn => unreachable, // this type will be deleted from the language
         }
     }
 
src/codegen/llvm.zig
@@ -2341,8 +2341,6 @@ pub const Object = struct {
             .Null => unreachable,
             .EnumLiteral => unreachable,
 
-            .BoundFn => @panic("TODO remove BoundFn from the language"),
-
             .Frame => @panic("TODO implement lowerDebugType for Frame types"),
             .AnyFrame => @panic("TODO implement lowerDebugType for AnyFrame types"),
         }
@@ -3095,8 +3093,6 @@ pub const DeclGen = struct {
             .Null => unreachable,
             .EnumLiteral => unreachable,
 
-            .BoundFn => @panic("TODO remove BoundFn from the language"),
-
             .Frame => @panic("TODO implement llvmType for Frame types"),
             .AnyFrame => @panic("TODO implement llvmType for AnyFrame types"),
         }
@@ -3896,7 +3892,6 @@ pub const DeclGen = struct {
             .NoReturn => unreachable,
             .Undefined => unreachable,
             .Null => unreachable,
-            .BoundFn => unreachable,
             .Opaque => unreachable,
 
             .Frame,
@@ -10792,7 +10787,6 @@ fn isByRef(ty: Type) bool {
         .EnumLiteral,
         .Undefined,
         .Null,
-        .BoundFn,
         .Opaque,
         => unreachable,
 
src/codegen/spirv.zig
@@ -538,8 +538,6 @@ pub const DeclGen = struct {
             .Type,
             => unreachable, // Must be comptime.
 
-            .BoundFn => unreachable, // this type will be deleted from the language.
-
             else => |tag| return self.todo("Implement zig type '{}'", .{tag}),
         };
     }
src/Autodoc.zig
@@ -607,7 +607,6 @@ const DocData = struct {
             is_test: bool = false,
             is_extern: bool = false,
         },
-        BoundFn: struct { name: []const u8 },
         Opaque: struct {
             name: []const u8,
             src: usize, // index into astNodes
src/Sema.zig
@@ -9275,7 +9275,6 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
                 dest_ty.fmt(sema.mod), container,
             });
         },
-        .BoundFn => @panic("TODO remove this type from the language and compiler"),
 
         .Array,
         .Bool,
@@ -9339,7 +9338,6 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
                 operand_ty.fmt(sema.mod), container,
             });
         },
-        .BoundFn => @panic("TODO remove this type from the language and compiler"),
 
         .Array,
         .Bool,
@@ -9777,7 +9775,6 @@ fn zirSwitchCond(
         .Undefined,
         .Null,
         .Optional,
-        .BoundFn,
         .Opaque,
         .Vector,
         .Frame,
@@ -10361,7 +10358,6 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
         .Undefined,
         .Null,
         .Optional,
-        .BoundFn,
         .Opaque,
         .Vector,
         .Frame,
@@ -14833,7 +14829,6 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
         .NoReturn,
         .Undefined,
         .Null,
-        .BoundFn,
         .Opaque,
         => return sema.fail(block, operand_src, "no size available for type '{}'", .{ty.fmt(sema.mod)}),
 
@@ -14877,7 +14872,6 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
         .NoReturn,
         .Undefined,
         .Null,
-        .BoundFn,
         .Opaque,
         => return sema.fail(block, operand_src, "no size available for type '{}'", .{operand_ty.fmt(sema.mod)}),
 
@@ -15908,7 +15902,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
                 }),
             );
         },
-        .BoundFn => @panic("TODO remove this type from the language and compiler"),
         .Frame => return sema.failWithUseOfAsync(block, src),
         .AnyFrame => return sema.failWithUseOfAsync(block, src),
     }
@@ -18609,7 +18602,6 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in
             const ty = try Type.Tag.function.create(sema.arena, fn_info);
             return sema.addType(ty);
         },
-        .BoundFn => @panic("TODO delete BoundFn from the language"),
         .Frame => return sema.failWithUseOfAsync(block, src),
     }
 }
@@ -21790,7 +21782,6 @@ fn validateRunTimeType(
 
         .Enum => return !(try sema.typeRequiresComptime(ty)),
 
-        .BoundFn,
         .ComptimeFloat,
         .ComptimeInt,
         .EnumLiteral,
@@ -21876,7 +21867,6 @@ fn explainWhyTypeIsComptimeInner(
             try mod.errNoteNonLazy(src_loc, msg, "types are not available at runtime", .{});
         },
 
-        .BoundFn,
         .ComptimeFloat,
         .ComptimeInt,
         .EnumLiteral,
@@ -21986,7 +21976,6 @@ fn validateExternType(
         .Null,
         .ErrorUnion,
         .ErrorSet,
-        .BoundFn,
         .Frame,
         => return false,
         .Void => return position == .union_field or position == .ret_ty,
@@ -22058,7 +22047,6 @@ fn explainWhyTypeIsNotExtern(
         .Null,
         .ErrorUnion,
         .ErrorSet,
-        .BoundFn,
         .Frame,
         => return,
 
@@ -22116,7 +22104,6 @@ fn validatePackedType(ty: Type) bool {
         .Null,
         .ErrorUnion,
         .ErrorSet,
-        .BoundFn,
         .Frame,
         .NoReturn,
         .Opaque,
@@ -22158,7 +22145,6 @@ fn explainWhyTypeIsNotPacked(
         .EnumLiteral,
         .Undefined,
         .Null,
-        .BoundFn,
         .Frame,
         .NoReturn,
         .Opaque,
src/type.zig
@@ -185,7 +185,6 @@ pub const Type = extern union {
             .Void,
             .ErrorSet,
             .Fn,
-            .BoundFn,
             .Opaque,
             .AnyFrame,
             .Enum,
@@ -4074,7 +4073,6 @@ pub const Type = extern union {
             => return true,
 
             .Opaque => return is_extern,
-            .BoundFn,
             .ComptimeFloat,
             .ComptimeInt,
             .EnumLiteral,
src/value.zig
@@ -2419,7 +2419,6 @@ pub const Value = extern union {
         if (val.tag() == .runtime_value) return;
 
         switch (zig_ty_tag) {
-            .BoundFn => unreachable, // TODO remove this from the language
             .Opaque => unreachable, // Cannot hash opaque types
 
             .Void,
@@ -2566,7 +2565,6 @@ pub const Value = extern union {
         if (val.tag() == .runtime_value) return;
 
         switch (ty.zigTypeTag()) {
-            .BoundFn => unreachable, // TODO remove this from the language
             .Opaque => unreachable, // Cannot hash opaque types
             .Void,
             .NoReturn,
test/behavior/type_info.zig
@@ -252,7 +252,7 @@ fn testUnion() !void {
     try expect(typeinfo_info == .Union);
     try expect(typeinfo_info.Union.layout == .Auto);
     try expect(typeinfo_info.Union.tag_type.? == TypeId);
-    try expect(typeinfo_info.Union.fields.len == 25);
+    try expect(typeinfo_info.Union.fields.len == 24);
     try expect(typeinfo_info.Union.fields[4].field_type == @TypeOf(@typeInfo(u8).Int));
     try expect(typeinfo_info.Union.decls.len == 22);