| author | |
| committer | |
| log | ffc5242169d67840e0d1420b792696fc1b3d1722 |
| tree | 3aa84fd640f75dd3ffe2b909e14ab0a95ed180b3 |
| parent | 5c41b6db87702017791b824ec9d76d5da00c354b |
| signature |
2 files changed, 22 insertions(+), 14 deletions(-)
src/Sema.zig+1-11| ... | @@ -19400,7 +19400,7 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -19400,7 +19400,7 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 19400 | const ty = try sema.resolveType(block, operand_src, inst_data.operand); | 19400 | const ty = try sema.resolveType(block, operand_src, inst_data.operand); |
| 19401 | try sema.ensureLayoutResolved(ty, operand_src, .align_of); | 19401 | try sema.ensureLayoutResolved(ty, operand_src, .align_of); |
| 19402 | if (ty.isNoReturn(zcu)) { | 19402 | if (ty.isNoReturn(zcu)) { |
| 19403 | return sema.fail(block, operand_src, "no align available for type '{f}'", .{ty.fmt(sema.pt)}); | 19403 | return sema.fail(block, operand_src, "no align available for uninstantiable type '{f}'", .{ty.fmt(sema.pt)}); |
| 19404 | } | 19404 | } |
| 19405 | return .fromValue(try pt.intValue(.comptime_int, ty.abiAlignment(zcu).toByteUnits().?)); | 19405 | return .fromValue(try pt.intValue(.comptime_int, ty.abiAlignment(zcu).toByteUnits().?)); |
| 19406 | } | 19406 | } |
| ... | @@ -33432,16 +33432,6 @@ fn errorSetMerge(sema: *Sema, lhs: Type, rhs: Type) !Type { | ... | @@ -33432,16 +33432,6 @@ fn errorSetMerge(sema: *Sema, lhs: Type, rhs: Type) !Type { |
| 33432 | return pt.errorSetFromUnsortedNames(names.keys()); | 33432 | return pt.errorSetFromUnsortedNames(names.keys()); |
| 33433 | } | 33433 | } |
| 33434 | 33434 | ||
| 33435 | /// Avoids crashing the compiler when asking if inferred allocations are noreturn. | ||
| 33436 | fn isNoReturn(sema: *Sema, ref: Air.Inst.Ref) bool { | ||
| 33437 | if (ref == .unreachable_value) return true; | ||
| 33438 | if (ref.toIndex()) |inst| switch (sema.air_instructions.items(.tag)[@intFromEnum(inst)]) { | ||
| 33439 | .inferred_alloc, .inferred_alloc_comptime => return false, | ||
| 33440 | else => {}, | ||
| 33441 | }; | ||
| 33442 | return sema.typeOf(ref).isNoReturn(sema.pt.zcu); | ||
| 33443 | } | ||
| 33444 | |||
| 33445 | pub fn declareDependency(sema: *Sema, dependee: InternPool.Dependee) !void { | 33435 | pub fn declareDependency(sema: *Sema, dependee: InternPool.Dependee) !void { |
| 33446 | const pt = sema.pt; | 33436 | const pt = sema.pt; |
| 33447 | if (!pt.zcu.comp.config.incremental) return; | 33437 | if (!pt.zcu.comp.config.incremental) return; |
src/Type.zig+21-3| ... | @@ -790,11 +790,21 @@ pub fn hasWellDefinedLayout(ty: Type, zcu: *const Zcu) bool { | ... | @@ -790,11 +790,21 @@ pub fn hasWellDefinedLayout(ty: Type, zcu: *const Zcu) bool { |
| 790 | /// function with this type can exist at runtime. | 790 | /// function with this type can exist at runtime. |
| 791 | /// Asserts that `ty` is a function type. | 791 | /// Asserts that `ty` is a function type. |
| 792 | pub fn fnHasRuntimeBits(fn_ty: Type, zcu: *Zcu) bool { | 792 | pub fn fnHasRuntimeBits(fn_ty: Type, zcu: *Zcu) bool { |
| 793 | assertHasLayout(fn_ty, zcu); | ||
| 793 | const fn_info = zcu.typeToFunc(fn_ty).?; | 794 | const fn_info = zcu.typeToFunc(fn_ty).?; |
| 794 | if (fn_info.comptime_bits != 0) return false; | 795 | if (fn_info.comptime_bits != 0) return false; |
| 795 | for (fn_info.param_types.get(&zcu.intern_pool)) |param_ty| { | 796 | for (fn_info.param_types.get(&zcu.intern_pool)) |param_ty| { |
| 796 | if (param_ty == .generic_poison_type) return false; | 797 | if (param_ty == .generic_poison_type) return false; |
| 797 | if (Type.fromInterned(param_ty).comptimeOnly(zcu)) return false; | 798 | switch (Type.fromInterned(param_ty).classify(zcu)) { |
| 799 | .fully_comptime, | ||
| 800 | .partially_comptime, | ||
| 801 | .no_possible_value, | ||
| 802 | => return false, | ||
| 803 | |||
| 804 | .one_possible_value, | ||
| 805 | .runtime, | ||
| 806 | => {}, | ||
| 807 | } | ||
| 798 | } | 808 | } |
| 799 | const ret_ty: Type = .fromInterned(fn_info.return_type); | 809 | const ret_ty: Type = .fromInterned(fn_info.return_type); |
| 800 | if (ret_ty.toIntern() == .generic_poison_type) { | 810 | if (ret_ty.toIntern() == .generic_poison_type) { |
| ... | @@ -805,8 +815,16 @@ pub fn fnHasRuntimeBits(fn_ty: Type, zcu: *Zcu) bool { | ... | @@ -805,8 +815,16 @@ pub fn fnHasRuntimeBits(fn_ty: Type, zcu: *Zcu) bool { |
| 805 | { | 815 | { |
| 806 | return false; | 816 | return false; |
| 807 | } | 817 | } |
| 808 | if (fn_info.return_type == .generic_poison_type) return false; | 818 | switch (ret_ty.classify(zcu)) { |
| 809 | if (Type.fromInterned(fn_info.return_type).comptimeOnly(zcu)) return false; | 819 | .fully_comptime, |
| 820 | .partially_comptime, | ||
| 821 | => return false, | ||
| 822 | |||
| 823 | .no_possible_value, | ||
| 824 | .one_possible_value, | ||
| 825 | .runtime, | ||
| 826 | => {}, | ||
| 827 | } | ||
| 810 | if (fn_info.cc == .@"inline") return false; | 828 | if (fn_info.cc == .@"inline") return false; |
| 811 | return true; | 829 | return true; |
| 812 | } | 830 | } |