Merge branch 'master' into pr/7345

This commit is contained in:
Jeroen van Rijn
2026-08-16 11:19:48 +02:00
14 changed files with 2099 additions and 33 deletions

View File

@@ -2244,7 +2244,10 @@ gb_internal LoadDirectiveResult check_load_directory_directive(CheckerContext *c
String name = bd->name.string;
GB_ASSERT(name == "load_directory");
if (ce->args.count != 1) {
if (ce->args.count == 0) {
error(ce->close, "'#%.*s' expects 1 argument, got 0", LIT(name));
return LoadDirective_Error;
} else if (ce->args.count != 1) {
error(ce->args[0], "'#%.*s' expects 1 argument, got %td", LIT(name), ce->args.count);
return LoadDirective_Error;
}

View File

@@ -3343,27 +3343,29 @@ gb_internal void check_comparison(CheckerContext *c, Ast *node, Operand *x, Oper
case Token_Lt:
case Token_LtEq:
{
// subset: (lhs & rhs) == lhs. a proper subset also requires lhs != rhs
ExactValue lhs = x->value;
ExactValue rhs = y->value;
ExactValue res = exact_binary_operator_value(Token_And, lhs, rhs);
res = exact_value_bool(compare_exact_values(op, res, lhs));
ExactValue both = exact_binary_operator_value(Token_And, lhs, rhs);
bool res = compare_exact_values(Token_CmpEq, both, lhs);
if (op == Token_Lt) {
res = exact_binary_operator_value(Token_And, res, exact_value_bool(compare_exact_values(op, lhs, rhs)));
res = res && compare_exact_values(Token_NotEq, lhs, rhs);
}
x->value = res;
x->value = exact_value_bool(res);
break;
}
case Token_Gt:
case Token_GtEq:
{
// superset: (lhs & rhs) == rhs
ExactValue lhs = x->value;
ExactValue rhs = y->value;
ExactValue res = exact_binary_operator_value(Token_And, lhs, rhs);
res = exact_value_bool(compare_exact_values(op, res, rhs));
ExactValue both = exact_binary_operator_value(Token_And, lhs, rhs);
bool res = compare_exact_values(Token_CmpEq, both, rhs);
if (op == Token_Gt) {
res = exact_binary_operator_value(Token_And, res, exact_value_bool(compare_exact_values(op, lhs, rhs)));
res = res && compare_exact_values(Token_NotEq, lhs, rhs);
}
x->value = res;
x->value = exact_value_bool(res);
break;
}
}

View File

@@ -1368,7 +1368,7 @@ gb_internal void check_bit_set_type(CheckerContext *c, Type *type, Type *named_t
gb_free(a, s.text);
return;
}
if (!check_representable_as_constant(c, iv, t, nullptr)) {
if (!check_representable_as_constant(c, jv, t, nullptr)) {
gbAllocator a = heap_allocator();
String s = big_int_to_string(a, &j);
gbString ts = type_to_string(t);

View File

@@ -1740,7 +1740,13 @@ gb_internal void lb_build_unroll_range_stmt(lbProcedure *p, AstUnrollRangeStmt *
slice = lb_emit_load(p, slice);
} else {
count_ptr = lb_add_local_generated(p, t_int, false).addr;
lb_emit_store(p, count_ptr, lb_slice_len(p, slice));
if (t->kind == Type_Slice) {
lb_emit_store(p, count_ptr, lb_slice_len(p, slice));
} else if (t->kind == Type_DynamicArray) {
lb_emit_store(p, count_ptr, lb_dynamic_array_len(p, slice));
} else {
GB_ASSERT_MSG(false, "Need to add support for this type.");
}
}
data_ptr = lb_emit_struct_ev(p, slice, 0);
break;

View File

@@ -1446,11 +1446,13 @@ gb_internal bool is_type_ordered(Type *t) {
return false;
}
gb_internal bool is_type_ordered_numeric(Type *t) {
t = core_type(t);
t = base_type(t);
if (t == nullptr) { return false; }
switch (t->kind) {
case Type_Basic:
return (t->Basic.flags & BasicFlag_OrderedNumeric) != 0;
case Type_Enum:
return is_type_ordered_numeric(t->Enum.base_type);
}
return false;
}