mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
Merge pull request #16495 from ziglang/bun
fix recent compiler regressions found when compiling bun
This commit is contained in:
commit
1bf16b1723
42
src/Sema.zig
42
src/Sema.zig
@ -30706,6 +30706,41 @@ fn analyzeIsNonErrComptimeOnly(
|
|||||||
const set_ty = ip.errorUnionSet(operand_ty.toIntern());
|
const set_ty = ip.errorUnionSet(operand_ty.toIntern());
|
||||||
switch (set_ty) {
|
switch (set_ty) {
|
||||||
.anyerror_type => {},
|
.anyerror_type => {},
|
||||||
|
.adhoc_inferred_error_set_type => if (sema.fn_ret_ty_ies) |ies| blk: {
|
||||||
|
// If the error set is empty, we must return a comptime true or false.
|
||||||
|
// However we want to avoid unnecessarily resolving an inferred error set
|
||||||
|
// in case it is already non-empty.
|
||||||
|
switch (ies.resolved) {
|
||||||
|
.anyerror_type => break :blk,
|
||||||
|
.none => {},
|
||||||
|
else => |i| if (ip.indexToKey(i).error_set_type.names.len != 0) break :blk,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maybe_operand_val != null) break :blk;
|
||||||
|
|
||||||
|
// Try to avoid resolving inferred error set if possible.
|
||||||
|
if (ies.errors.count() != 0) return .none;
|
||||||
|
switch (ies.resolved) {
|
||||||
|
.anyerror_type => return .none,
|
||||||
|
.none => {},
|
||||||
|
else => switch (ip.indexToKey(ies.resolved).error_set_type.names.len) {
|
||||||
|
0 => return .bool_true,
|
||||||
|
else => return .none,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for (ies.inferred_error_sets.keys()) |other_ies_index| {
|
||||||
|
if (set_ty == other_ies_index) continue;
|
||||||
|
const other_resolved =
|
||||||
|
try sema.resolveInferredErrorSet(block, src, other_ies_index);
|
||||||
|
if (other_resolved == .anyerror_type) {
|
||||||
|
ies.resolved = .anyerror_type;
|
||||||
|
return .none;
|
||||||
|
}
|
||||||
|
if (ip.indexToKey(other_resolved).error_set_type.names.len != 0)
|
||||||
|
return .none;
|
||||||
|
}
|
||||||
|
return .bool_true;
|
||||||
|
},
|
||||||
else => switch (ip.indexToKey(set_ty)) {
|
else => switch (ip.indexToKey(set_ty)) {
|
||||||
.error_set_type => |error_set_type| {
|
.error_set_type => |error_set_type| {
|
||||||
if (error_set_type.names.len == 0) return .bool_true;
|
if (error_set_type.names.len == 0) return .bool_true;
|
||||||
@ -30719,11 +30754,9 @@ fn analyzeIsNonErrComptimeOnly(
|
|||||||
.none => {},
|
.none => {},
|
||||||
else => |i| if (ip.indexToKey(i).error_set_type.names.len != 0) break :blk,
|
else => |i| if (ip.indexToKey(i).error_set_type.names.len != 0) break :blk,
|
||||||
}
|
}
|
||||||
if (maybe_operand_val == null) {
|
if (maybe_operand_val != null) break :blk;
|
||||||
if (sema.fn_ret_ty_ies) |ies| {
|
if (sema.fn_ret_ty_ies) |ies| {
|
||||||
if (set_ty == .adhoc_inferred_error_set_type or
|
if (ies.func == func_index) {
|
||||||
ies.func == func_index)
|
|
||||||
{
|
|
||||||
// Try to avoid resolving inferred error set if possible.
|
// Try to avoid resolving inferred error set if possible.
|
||||||
if (ies.errors.count() != 0) return .none;
|
if (ies.errors.count() != 0) return .none;
|
||||||
switch (ies.resolved) {
|
switch (ies.resolved) {
|
||||||
@ -30753,7 +30786,6 @@ fn analyzeIsNonErrComptimeOnly(
|
|||||||
break :blk;
|
break :blk;
|
||||||
if (ip.indexToKey(resolved_ty).error_set_type.names.len == 0)
|
if (ip.indexToKey(resolved_ty).error_set_type.names.len == 0)
|
||||||
return .bool_true;
|
return .bool_true;
|
||||||
}
|
|
||||||
},
|
},
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -2065,7 +2065,7 @@ pub const Type = struct {
|
|||||||
pub fn errorSetIsEmpty(ty: Type, mod: *Module) bool {
|
pub fn errorSetIsEmpty(ty: Type, mod: *Module) bool {
|
||||||
const ip = &mod.intern_pool;
|
const ip = &mod.intern_pool;
|
||||||
return switch (ty.toIntern()) {
|
return switch (ty.toIntern()) {
|
||||||
.anyerror_type => false,
|
.anyerror_type, .adhoc_inferred_error_set_type => false,
|
||||||
else => switch (ip.indexToKey(ty.toIntern())) {
|
else => switch (ip.indexToKey(ty.toIntern())) {
|
||||||
.error_set_type => |error_set_type| error_set_type.names.len == 0,
|
.error_set_type => |error_set_type| error_set_type.names.len == 0,
|
||||||
.inferred_error_set_type => |i| switch (ip.funcIesResolved(i).*) {
|
.inferred_error_set_type => |i| switch (ip.funcIesResolved(i).*) {
|
||||||
@ -2084,6 +2084,7 @@ pub const Type = struct {
|
|||||||
const ip = &mod.intern_pool;
|
const ip = &mod.intern_pool;
|
||||||
return switch (ty.toIntern()) {
|
return switch (ty.toIntern()) {
|
||||||
.anyerror_type => true,
|
.anyerror_type => true,
|
||||||
|
.adhoc_inferred_error_set_type => false,
|
||||||
else => switch (mod.intern_pool.indexToKey(ty.toIntern())) {
|
else => switch (mod.intern_pool.indexToKey(ty.toIntern())) {
|
||||||
.inferred_error_set_type => |i| ip.funcIesResolved(i).* == .anyerror_type,
|
.inferred_error_set_type => |i| ip.funcIesResolved(i).* == .anyerror_type,
|
||||||
else => false,
|
else => false,
|
||||||
|
|||||||
@ -483,10 +483,10 @@ pub const Value = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn getFunction(val: Value, mod: *Module) ?InternPool.Key.Func {
|
pub fn getFunction(val: Value, mod: *Module) ?InternPool.Key.Func {
|
||||||
return switch (mod.intern_pool.indexToKey(val.toIntern())) {
|
return if (val.ip_index != .none) switch (mod.intern_pool.indexToKey(val.toIntern())) {
|
||||||
.func => |x| x,
|
.func => |x| x,
|
||||||
else => null,
|
else => null,
|
||||||
};
|
} else null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getExternFunc(val: Value, mod: *Module) ?InternPool.Key.ExternFunc {
|
pub fn getExternFunc(val: Value, mod: *Module) ?InternPool.Key.ExternFunc {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user