| ... | @@ -47,8 +47,6 @@ pub const Type = struct { | ... | @@ -47,8 +47,6 @@ pub const Type = struct { |
| 47 | .inferred_alloc_mut, | 47 | .inferred_alloc_mut, |
| 48 | => return .Pointer, | 48 | => return .Pointer, |
| 49 | | 49 | |
| 50 | .optional => return .Optional, | | |
| 51 | | | |
| 52 | .error_union => return .ErrorUnion, | 50 | .error_union => return .ErrorUnion, |
| 53 | }, | 51 | }, |
| 54 | else => return switch (mod.intern_pool.indexToKey(ty.ip_index)) { | 52 | else => return switch (mod.intern_pool.indexToKey(ty.ip_index)) { |
| ... | @@ -283,10 +281,6 @@ pub const Type = struct { | ... | @@ -283,10 +281,6 @@ pub const Type = struct { |
| 283 | return switch (ty.ip_index) { | 281 | return switch (ty.ip_index) { |
| 284 | .none => switch (ty.tag()) { | 282 | .none => switch (ty.tag()) { |
| 285 | .pointer => ty.castTag(.pointer).?.data, | 283 | .pointer => ty.castTag(.pointer).?.data, |
| 286 | .optional => b: { | | |
| 287 | const child_type = ty.optionalChild(mod); | | |
| 288 | break :b child_type.ptrInfo(mod); | | |
| 289 | }, | | |
| 290 | | 284 | |
| 291 | else => unreachable, | 285 | else => unreachable, |
| 292 | }, | 286 | }, |
| ... | @@ -387,12 +381,6 @@ pub const Type = struct { | ... | @@ -387,12 +381,6 @@ pub const Type = struct { |
| 387 | return true; | 381 | return true; |
| 388 | }, | 382 | }, |
| 389 | | 383 | |
| 390 | .optional => { | | |
| 391 | if (b.zigTypeTag(mod) != .Optional) return false; | | |
| 392 | | | |
| 393 | return a.optionalChild(mod).eql(b.optionalChild(mod), mod); | | |
| 394 | }, | | |
| 395 | | | |
| 396 | .error_union => { | 384 | .error_union => { |
| 397 | if (b.zigTypeTag(mod) != .ErrorUnion) return false; | 385 | if (b.zigTypeTag(mod) != .ErrorUnion) return false; |
| 398 | | 386 | |
| ... | @@ -466,12 +454,6 @@ pub const Type = struct { | ... | @@ -466,12 +454,6 @@ pub const Type = struct { |
| 466 | std.hash.autoHash(hasher, info.size); | 454 | std.hash.autoHash(hasher, info.size); |
| 467 | }, | 455 | }, |
| 468 | | 456 | |
| 469 | .optional => { | | |
| 470 | std.hash.autoHash(hasher, std.builtin.TypeId.Optional); | | |
| 471 | | | |
| 472 | hashWithHasher(ty.optionalChild(mod), hasher, mod); | | |
| 473 | }, | | |
| 474 | | | |
| 475 | .error_union => { | 457 | .error_union => { |
| 476 | std.hash.autoHash(hasher, std.builtin.TypeId.ErrorUnion); | 458 | std.hash.autoHash(hasher, std.builtin.TypeId.ErrorUnion); |
| 477 | | 459 | |
| ... | @@ -530,19 +512,6 @@ pub const Type = struct { | ... | @@ -530,19 +512,6 @@ pub const Type = struct { |
| 530 | .inferred_alloc_mut, | 512 | .inferred_alloc_mut, |
| 531 | => unreachable, | 513 | => unreachable, |
| 532 | | 514 | |
| 533 | .optional => { | | |
| 534 | const payload = self.cast(Payload.ElemType).?; | | |
| 535 | const new_payload = try allocator.create(Payload.ElemType); | | |
| 536 | new_payload.* = .{ | | |
| 537 | .base = .{ .tag = payload.base.tag }, | | |
| 538 | .data = try payload.data.copy(allocator), | | |
| 539 | }; | | |
| 540 | return Type{ | | |
| 541 | .ip_index = .none, | | |
| 542 | .legacy = .{ .ptr_otherwise = &new_payload.base }, | | |
| 543 | }; | | |
| 544 | }, | | |
| 545 | | | |
| 546 | .pointer => { | 515 | .pointer => { |
| 547 | const payload = self.castTag(.pointer).?.data; | 516 | const payload = self.castTag(.pointer).?.data; |
| 548 | const sent: ?Value = if (payload.sentinel) |some| | 517 | const sent: ?Value = if (payload.sentinel) |some| |
| ... | @@ -654,13 +623,6 @@ pub const Type = struct { | ... | @@ -654,13 +623,6 @@ pub const Type = struct { |
| 654 | while (true) { | 623 | while (true) { |
| 655 | const t = ty.tag(); | 624 | const t = ty.tag(); |
| 656 | switch (t) { | 625 | switch (t) { |
| 657 | .optional => { | | |
| 658 | const child_type = ty.castTag(.optional).?.data; | | |
| 659 | try writer.writeByte('?'); | | |
| 660 | ty = child_type; | | |
| 661 | continue; | | |
| 662 | }, | | |
| 663 | | | |
| 664 | .pointer => { | 626 | .pointer => { |
| 665 | const payload = ty.castTag(.pointer).?.data; | 627 | const payload = ty.castTag(.pointer).?.data; |
| 666 | if (payload.sentinel) |some| switch (payload.size) { | 628 | if (payload.sentinel) |some| switch (payload.size) { |
| ... | @@ -813,11 +775,6 @@ pub const Type = struct { | ... | @@ -813,11 +775,6 @@ pub const Type = struct { |
| 813 | try print(info.pointee_type, writer, mod); | 775 | try print(info.pointee_type, writer, mod); |
| 814 | }, | 776 | }, |
| 815 | | 777 | |
| 816 | .optional => { | | |
| 817 | const child_type = ty.castTag(.optional).?.data; | | |
| 818 | try writer.writeByte('?'); | | |
| 819 | try print(child_type, writer, mod); | | |
| 820 | }, | | |
| 821 | .error_set => { | 778 | .error_set => { |
| 822 | const names = ty.castTag(.error_set).?.data.names.keys(); | 779 | const names = ty.castTag(.error_set).?.data.names.keys(); |
| 823 | try writer.writeAll("error{"); | 780 | try writer.writeAll("error{"); |
| ... | @@ -911,8 +868,7 @@ pub const Type = struct { | ... | @@ -911,8 +868,7 @@ pub const Type = struct { |
| 911 | }, | 868 | }, |
| 912 | .opt_type => |child| { | 869 | .opt_type => |child| { |
| 913 | try writer.writeByte('?'); | 870 | try writer.writeByte('?'); |
| 914 | try print(child.toType(), writer, mod); | 871 | return print(child.toType(), writer, mod); |
| 915 | return; | | |
| 916 | }, | 872 | }, |
| 917 | .error_union_type => |error_union_type| { | 873 | .error_union_type => |error_union_type| { |
| 918 | try print(error_union_type.error_set_type.toType(), writer, mod); | 874 | try print(error_union_type.error_set_type.toType(), writer, mod); |
| ... | @@ -1090,21 +1046,6 @@ pub const Type = struct { | ... | @@ -1090,21 +1046,6 @@ pub const Type = struct { |
| 1090 | } | 1046 | } |
| 1091 | }, | 1047 | }, |
| 1092 | | 1048 | |
| 1093 | .optional => { | | |
| 1094 | const child_ty = ty.optionalChild(mod); | | |
| 1095 | if (child_ty.isNoReturn()) { | | |
| 1096 | // Then the optional is comptime-known to be null. | | |
| 1097 | return false; | | |
| 1098 | } | | |
| 1099 | if (ignore_comptime_only) { | | |
| 1100 | return true; | | |
| 1101 | } else if (strat == .sema) { | | |
| 1102 | return !(try strat.sema.typeRequiresComptime(child_ty)); | | |
| 1103 | } else { | | |
| 1104 | return !comptimeOnly(child_ty, mod); | | |
| 1105 | } | | |
| 1106 | }, | | |
| 1107 | | | |
| 1108 | .inferred_alloc_const => unreachable, | 1049 | .inferred_alloc_const => unreachable, |
| 1109 | .inferred_alloc_mut => unreachable, | 1050 | .inferred_alloc_mut => unreachable, |
| 1110 | }, | 1051 | }, |
| ... | @@ -1301,8 +1242,6 @@ pub const Type = struct { | ... | @@ -1301,8 +1242,6 @@ pub const Type = struct { |
| 1301 | | 1242 | |
| 1302 | .inferred_alloc_mut => unreachable, | 1243 | .inferred_alloc_mut => unreachable, |
| 1303 | .inferred_alloc_const => unreachable, | 1244 | .inferred_alloc_const => unreachable, |
| 1304 | | | |
| 1305 | .optional => ty.isPtrLikeOptional(mod), | | |
| 1306 | }, | 1245 | }, |
| 1307 | else => switch (mod.intern_pool.indexToKey(ty.ip_index)) { | 1246 | else => switch (mod.intern_pool.indexToKey(ty.ip_index)) { |
| 1308 | .int_type, | 1247 | .int_type, |
| ... | @@ -1319,7 +1258,7 @@ pub const Type = struct { | ... | @@ -1319,7 +1258,7 @@ pub const Type = struct { |
| 1319 | => false, | 1258 | => false, |
| 1320 | | 1259 | |
| 1321 | .array_type => |array_type| array_type.child.toType().hasWellDefinedLayout(mod), | 1260 | .array_type => |array_type| array_type.child.toType().hasWellDefinedLayout(mod), |
| 1322 | .opt_type => |child| child.toType().isPtrLikeOptional(mod), | 1261 | .opt_type => ty.isPtrLikeOptional(mod), |
| 1323 | | 1262 | |
| 1324 | .simple_type => |t| switch (t) { | 1263 | .simple_type => |t| switch (t) { |
| 1325 | .f16, | 1264 | .f16, |
| ... | @@ -1484,7 +1423,6 @@ pub const Type = struct { | ... | @@ -1484,7 +1423,6 @@ pub const Type = struct { |
| 1484 | return (ptr_info.pointee_type.abiAlignmentAdvanced(mod, .eager) catch unreachable).scalar; | 1423 | return (ptr_info.pointee_type.abiAlignmentAdvanced(mod, .eager) catch unreachable).scalar; |
| 1485 | } | 1424 | } |
| 1486 | }, | 1425 | }, |
| 1487 | .optional => return ty.castTag(.optional).?.data.ptrAlignmentAdvanced(mod, opt_sema), | | |
| 1488 | | 1426 | |
| 1489 | else => unreachable, | 1427 | else => unreachable, |
| 1490 | }, | 1428 | }, |
| ... | @@ -1510,11 +1448,6 @@ pub const Type = struct { | ... | @@ -1510,11 +1448,6 @@ pub const Type = struct { |
| 1510 | .none => switch (ty.tag()) { | 1448 | .none => switch (ty.tag()) { |
| 1511 | .pointer => ty.castTag(.pointer).?.data.@"addrspace", | 1449 | .pointer => ty.castTag(.pointer).?.data.@"addrspace", |
| 1512 | | 1450 | |
| 1513 | .optional => { | | |
| 1514 | const child_type = ty.optionalChild(mod); | | |
| 1515 | return child_type.ptrAddressSpace(mod); | | |
| 1516 | }, | | |
| 1517 | | | |
| 1518 | else => unreachable, | 1451 | else => unreachable, |
| 1519 | }, | 1452 | }, |
| 1520 | else => switch (mod.intern_pool.indexToKey(ty.ip_index)) { | 1453 | else => switch (mod.intern_pool.indexToKey(ty.ip_index)) { |
| ... | @@ -1580,7 +1513,6 @@ pub const Type = struct { | ... | @@ -1580,7 +1513,6 @@ pub const Type = struct { |
| 1580 | .error_set_merged, | 1513 | .error_set_merged, |
| 1581 | => return AbiAlignmentAdvanced{ .scalar = 2 }, | 1514 | => return AbiAlignmentAdvanced{ .scalar = 2 }, |
| 1582 | | 1515 | |
| 1583 | .optional => return abiAlignmentAdvancedOptional(ty, mod, strat), | | |
| 1584 | .error_union => return abiAlignmentAdvancedErrorUnion(ty, mod, strat), | 1516 | .error_union => return abiAlignmentAdvancedErrorUnion(ty, mod, strat), |
| 1585 | | 1517 | |
| 1586 | .inferred_alloc_const, | 1518 | .inferred_alloc_const, |
| ... | @@ -1962,8 +1894,6 @@ pub const Type = struct { | ... | @@ -1962,8 +1894,6 @@ pub const Type = struct { |
| 1962 | .error_set_single, | 1894 | .error_set_single, |
| 1963 | => return AbiSizeAdvanced{ .scalar = 2 }, | 1895 | => return AbiSizeAdvanced{ .scalar = 2 }, |
| 1964 | | 1896 | |
| 1965 | .optional => return ty.abiSizeAdvancedOptional(mod, strat), | | |
| 1966 | | | |
| 1967 | .error_union => { | 1897 | .error_union => { |
| 1968 | // This code needs to be kept in sync with the equivalent switch prong | 1898 | // This code needs to be kept in sync with the equivalent switch prong |
| 1969 | // in abiAlignmentAdvanced. | 1899 | // in abiAlignmentAdvanced. |
| ... | @@ -2282,7 +2212,7 @@ pub const Type = struct { | ... | @@ -2282,7 +2212,7 @@ pub const Type = struct { |
| 2282 | .error_set_merged, | 2212 | .error_set_merged, |
| 2283 | => return 16, // TODO revisit this when we have the concept of the error tag type | 2213 | => return 16, // TODO revisit this when we have the concept of the error tag type |
| 2284 | | 2214 | |
| 2285 | .optional, .error_union => { | 2215 | .error_union => { |
| 2286 | // Optionals and error unions are not packed so their bitsize | 2216 | // Optionals and error unions are not packed so their bitsize |
| 2287 | // includes padding bits. | 2217 | // includes padding bits. |
| 2288 | return (try abiSizeAdvanced(ty, mod, strat)).scalar * 8; | 2218 | return (try abiSizeAdvanced(ty, mod, strat)).scalar * 8; |
| ... | @@ -2310,7 +2240,11 @@ pub const Type = struct { | ... | @@ -2310,7 +2240,11 @@ pub const Type = struct { |
| 2310 | const elem_bit_size = try bitSizeAdvanced(child_ty, mod, opt_sema); | 2240 | const elem_bit_size = try bitSizeAdvanced(child_ty, mod, opt_sema); |
| 2311 | return elem_bit_size * vector_type.len; | 2241 | return elem_bit_size * vector_type.len; |
| 2312 | }, | 2242 | }, |
| 2313 | .opt_type => @panic("TODO"), | 2243 | .opt_type => { |
| | 2244 | // Optionals and error unions are not packed so their bitsize |
| | 2245 | // includes padding bits. |
| | 2246 | return (try abiSizeAdvanced(ty, mod, strat)).scalar * 8; |
| | 2247 | }, |
| 2314 | .error_union_type => @panic("TODO"), | 2248 | .error_union_type => @panic("TODO"), |
| 2315 | .func_type => unreachable, // represents machine code; not a pointer | 2249 | .func_type => unreachable, // represents machine code; not a pointer |
| 2316 | .simple_type => |t| switch (t) { | 2250 | .simple_type => |t| switch (t) { |
| ... | @@ -2499,7 +2433,6 @@ pub const Type = struct { | ... | @@ -2499,7 +2433,6 @@ pub const Type = struct { |
| 2499 | } | 2433 | } |
| 2500 | | 2434 | |
| 2501 | pub const SlicePtrFieldTypeBuffer = union { | 2435 | pub const SlicePtrFieldTypeBuffer = union { |
| 2502 | elem_type: Payload.ElemType, | | |
| 2503 | pointer: Payload.Pointer, | 2436 | pointer: Payload.Pointer, |
| 2504 | }; | 2437 | }; |
| 2505 | | 2438 | |
| ... | @@ -2600,16 +2533,6 @@ pub const Type = struct { | ... | @@ -2600,16 +2533,6 @@ pub const Type = struct { |
| 2600 | .One, .Many, .C => return true, | 2533 | .One, .Many, .C => return true, |
| 2601 | }, | 2534 | }, |
| 2602 | | 2535 | |
| 2603 | .optional => { | | |
| 2604 | const child_type = ty.optionalChild(mod); | | |
| 2605 | if (child_type.zigTypeTag(mod) != .Pointer) return false; | | |
| 2606 | const info = child_type.ptrInfo(mod); | | |
| 2607 | switch (info.size) { | | |
| 2608 | .Slice, .C => return false, | | |
| 2609 | .Many, .One => return !info.@"allowzero", | | |
| 2610 | } | | |
| 2611 | }, | | |
| 2612 | | | |
| 2613 | else => return false, | 2536 | else => return false, |
| 2614 | }, | 2537 | }, |
| 2615 | else => return switch (mod.intern_pool.indexToKey(ty.ip_index)) { | 2538 | else => return switch (mod.intern_pool.indexToKey(ty.ip_index)) { |
| ... | @@ -2655,21 +2578,6 @@ pub const Type = struct { | ... | @@ -2655,21 +2578,6 @@ pub const Type = struct { |
| 2655 | else => false, | 2578 | else => false, |
| 2656 | }; | 2579 | }; |
| 2657 | switch (ty.tag()) { | 2580 | switch (ty.tag()) { |
| 2658 | .optional => { | | |
| 2659 | const child_ty = ty.castTag(.optional).?.data; | | |
| 2660 | switch (child_ty.zigTypeTag(mod)) { | | |
| 2661 | .Pointer => { | | |
| 2662 | const info = child_ty.ptrInfo(mod); | | |
| 2663 | switch (info.size) { | | |
| 2664 | .C => return false, | | |
| 2665 | .Slice, .Many, .One => return !info.@"allowzero", | | |
| 2666 | } | | |
| 2667 | }, | | |
| 2668 | .ErrorSet => return true, | | |
| 2669 | else => return false, | | |
| 2670 | } | | |
| 2671 | }, | | |
| 2672 | | | |
| 2673 | .pointer => return ty.castTag(.pointer).?.data.size == .C, | 2581 | .pointer => return ty.castTag(.pointer).?.data.size == .C, |
| 2674 | | 2582 | |
| 2675 | else => return false, | 2583 | else => return false, |
| ... | @@ -2692,16 +2600,6 @@ pub const Type = struct { | ... | @@ -2692,16 +2600,6 @@ pub const Type = struct { |
| 2692 | else => false, | 2600 | else => false, |
| 2693 | }; | 2601 | }; |
| 2694 | switch (ty.tag()) { | 2602 | switch (ty.tag()) { |
| 2695 | .optional => { | | |
| 2696 | const child_ty = ty.castTag(.optional).?.data; | | |
| 2697 | if (child_ty.zigTypeTag(mod) != .Pointer) return false; | | |
| 2698 | const info = child_ty.ptrInfo(mod); | | |
| 2699 | switch (info.size) { | | |
| 2700 | .Slice, .C => return false, | | |
| 2701 | .Many, .One => return !info.@"allowzero", | | |
| 2702 | } | | |
| 2703 | }, | | |
| 2704 | | | |
| 2705 | .pointer => return ty.castTag(.pointer).?.data.size == .C, | 2603 | .pointer => return ty.castTag(.pointer).?.data.size == .C, |
| 2706 | | 2604 | |
| 2707 | else => return false, | 2605 | else => return false, |
| ... | @@ -2747,7 +2645,6 @@ pub const Type = struct { | ... | @@ -2747,7 +2645,6 @@ pub const Type = struct { |
| 2747 | return child_ty; | 2645 | return child_ty; |
| 2748 | } | 2646 | } |
| 2749 | }, | 2647 | }, |
| 2750 | .optional => ty.castTag(.optional).?.data.childType(mod), | | |
| 2751 | | 2648 | |
| 2752 | else => unreachable, | 2649 | else => unreachable, |
| 2753 | }, | 2650 | }, |
| ... | @@ -2784,13 +2681,10 @@ pub const Type = struct { | ... | @@ -2784,13 +2681,10 @@ pub const Type = struct { |
| 2784 | } | 2681 | } |
| 2785 | | 2682 | |
| 2786 | /// Asserts that the type is an optional. | 2683 | /// Asserts that the type is an optional. |
| 2787 | /// Resulting `Type` will have inner memory referencing `buf`. | | |
| 2788 | /// Note that for C pointers this returns the type unmodified. | 2684 | /// Note that for C pointers this returns the type unmodified. |
| 2789 | pub fn optionalChild(ty: Type, mod: *const Module) Type { | 2685 | pub fn optionalChild(ty: Type, mod: *const Module) Type { |
| 2790 | return switch (ty.ip_index) { | 2686 | return switch (ty.ip_index) { |
| 2791 | .none => switch (ty.tag()) { | 2687 | .none => switch (ty.tag()) { |
| 2792 | .optional => ty.castTag(.optional).?.data, | | |
| 2793 | | | |
| 2794 | .pointer, // here we assume it is a C pointer | 2688 | .pointer, // here we assume it is a C pointer |
| 2795 | => return ty, | 2689 | => return ty, |
| 2796 | | 2690 | |
| ... | @@ -3305,15 +3199,6 @@ pub const Type = struct { | ... | @@ -3305,15 +3199,6 @@ pub const Type = struct { |
| 3305 | .pointer, | 3199 | .pointer, |
| 3306 | => return null, | 3200 | => return null, |
| 3307 | | 3201 | |
| 3308 | .optional => { | | |
| 3309 | const child_ty = ty.optionalChild(mod); | | |
| 3310 | if (child_ty.isNoReturn()) { | | |
| 3311 | return Value.null; | | |
| 3312 | } else { | | |
| 3313 | return null; | | |
| 3314 | } | | |
| 3315 | }, | | |
| 3316 | | | |
| 3317 | .inferred_alloc_const => unreachable, | 3202 | .inferred_alloc_const => unreachable, |
| 3318 | .inferred_alloc_mut => unreachable, | 3203 | .inferred_alloc_mut => unreachable, |
| 3319 | }, | 3204 | }, |
| ... | @@ -3524,10 +3409,6 @@ pub const Type = struct { | ... | @@ -3524,10 +3409,6 @@ pub const Type = struct { |
| 3524 | } | 3409 | } |
| 3525 | }, | 3410 | }, |
| 3526 | | 3411 | |
| 3527 | .optional => { | | |
| 3528 | return ty.optionalChild(mod).comptimeOnly(mod); | | |
| 3529 | }, | | |
| 3530 | | | |
| 3531 | .error_union => return ty.errorUnionPayload().comptimeOnly(mod), | 3412 | .error_union => return ty.errorUnionPayload().comptimeOnly(mod), |
| 3532 | }, | 3413 | }, |
| 3533 | else => switch (mod.intern_pool.indexToKey(ty.ip_index)) { | 3414 | else => switch (mod.intern_pool.indexToKey(ty.ip_index)) { |
| ... | @@ -4216,7 +4097,6 @@ pub const Type = struct { | ... | @@ -4216,7 +4097,6 @@ pub const Type = struct { |
| 4216 | // After this, the tag requires a payload. | 4097 | // After this, the tag requires a payload. |
| 4217 | | 4098 | |
| 4218 | pointer, | 4099 | pointer, |
| 4219 | optional, | | |
| 4220 | error_union, | 4100 | error_union, |
| 4221 | error_set, | 4101 | error_set, |
| 4222 | error_set_single, | 4102 | error_set_single, |
| ... | @@ -4233,8 +4113,6 @@ pub const Type = struct { | ... | @@ -4233,8 +4113,6 @@ pub const Type = struct { |
| 4233 | .inferred_alloc_mut, | 4113 | .inferred_alloc_mut, |
| 4234 | => @compileError("Type Tag " ++ @tagName(t) ++ " has no payload"), | 4114 | => @compileError("Type Tag " ++ @tagName(t) ++ " has no payload"), |
| 4235 | | 4115 | |
| 4236 | .optional => Payload.ElemType, | | |
| 4237 | | | |
| 4238 | .error_set => Payload.ErrorSet, | 4116 | .error_set => Payload.ErrorSet, |
| 4239 | .error_set_inferred => Payload.ErrorSetInferred, | 4117 | .error_set_inferred => Payload.ErrorSetInferred, |
| 4240 | .error_set_merged => Payload.ErrorSetMerged, | 4118 | .error_set_merged => Payload.ErrorSetMerged, |
| ... | @@ -4326,11 +4204,6 @@ pub const Type = struct { | ... | @@ -4326,11 +4204,6 @@ pub const Type = struct { |
| 4326 | data: u64, | 4204 | data: u64, |
| 4327 | }; | 4205 | }; |
| 4328 | | 4206 | |
| 4329 | pub const ElemType = struct { | | |
| 4330 | base: Payload, | | |
| 4331 | data: Type, | | |
| 4332 | }; | | |
| 4333 | | | |
| 4334 | pub const Bits = struct { | 4207 | pub const Bits = struct { |
| 4335 | base: Payload, | 4208 | base: Payload, |
| 4336 | data: u16, | 4209 | data: u16, |
| ... | @@ -4570,11 +4443,11 @@ pub const Type = struct { | ... | @@ -4570,11 +4443,11 @@ pub const Type = struct { |
| 4570 | } | 4443 | } |
| 4571 | | 4444 | |
| 4572 | pub fn optional(arena: Allocator, child_type: Type, mod: *Module) Allocator.Error!Type { | 4445 | pub fn optional(arena: Allocator, child_type: Type, mod: *Module) Allocator.Error!Type { |
| 4573 | if (child_type.ip_index != .none) { | 4446 | // TODO: update callsites of this function to directly call |
| 4574 | return mod.optionalType(child_type.ip_index); | 4447 | // mod.optionalType and then delete this function. |
| 4575 | } else { | 4448 | _ = arena; |
| 4576 | return Type.Tag.optional.create(arena, child_type); | 4449 | |
| 4577 | } | 4450 | return mod.optionalType(child_type.ip_index); |
| 4578 | } | 4451 | } |
| 4579 | | 4452 | |
| 4580 | pub fn errorUnion( | 4453 | pub fn errorUnion( |