Skip to content

Commit cc6d869

Browse files
committed
Fix some tests
1 parent 0b86661 commit cc6d869

File tree

119 files changed

+1841
-500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+1841
-500
lines changed

src/check/Check.zig

Lines changed: 1 addition & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -3116,53 +3116,19 @@ fn checkExpr(self: *Self, expr_idx: CIR.Expr.Idx, env: *Env, expected: Expected)
31163116
expr_region,
31173117
);
31183118

3119-
std.debug.print(" Created constraint - constrained_var: {d}\n", .{@intFromEnum(constrained_var)});
3120-
31213119
// Unify constraint function args with actual expression vars
31223120
// This propagates types from the actual expressions to the constraint function
31233121
_ = try self.unify(constraint_receiver_var, receiver_var, env);
3124-
std.debug.print(" Unified constraint_receiver with receiver\n", .{});
31253122
for (dispatch_arg_expr_idxs, 0..) |arg_expr_idx, i| {
31263123
const actual_arg_var = ModuleEnv.varFrom(arg_expr_idx);
3127-
const constraint_arg_resolved = self.types.resolveVar(constraint_args_buf[i]);
3128-
const actual_arg_resolved = self.types.resolveVar(actual_arg_var);
3129-
std.debug.print(" BEFORE unifying constraint arg[{d}]:\n", .{i});
3130-
std.debug.print(" constraint_arg var={d}, content={s}", .{
3131-
@intFromEnum(constraint_arg_resolved.var_),
3132-
@tagName(constraint_arg_resolved.desc.content),
3133-
});
3134-
if (constraint_arg_resolved.desc.content == .structure and constraint_arg_resolved.desc.content.structure == .num) {
3135-
std.debug.print(" num={s}", .{@tagName(constraint_arg_resolved.desc.content.structure.num)});
3136-
}
3137-
std.debug.print("\n", .{});
3138-
std.debug.print(" actual_arg var={d}, content={s}", .{
3139-
@intFromEnum(actual_arg_resolved.var_),
3140-
@tagName(actual_arg_resolved.desc.content),
3141-
});
3142-
if (actual_arg_resolved.desc.content == .structure and actual_arg_resolved.desc.content.structure == .num) {
3143-
std.debug.print(" num={s}", .{@tagName(actual_arg_resolved.desc.content.structure.num)});
3144-
}
3145-
std.debug.print("\n", .{});
31463124
_ = try self.unify(constraint_args_buf[i], actual_arg_var, env);
3147-
const after_resolved = self.types.resolveVar(constraint_args_buf[i]);
3148-
std.debug.print(" AFTER unify: constraint_arg content={s}", .{@tagName(after_resolved.desc.content)});
3149-
if (after_resolved.desc.content == .structure and after_resolved.desc.content.structure == .num) {
3150-
std.debug.print(" num={s}", .{@tagName(after_resolved.desc.content.structure.num)});
3151-
}
3152-
std.debug.print("\n", .{});
31533125
}
31543126

31553127
// Unify constrained var with receiver (this attaches the constraint to the receiver type)
3156-
std.debug.print(" About to unify constrained_var ({d}) with receiver_var ({d})\n", .{
3157-
@intFromEnum(constrained_var),
3158-
@intFromEnum(receiver_var),
3159-
});
3160-
const unify_result = try self.unify(constrained_var, receiver_var, env);
3161-
std.debug.print(" Unify result: isProblem={}\n", .{unify_result.isProblem()});
3128+
_ = try self.unify(constrained_var, receiver_var, env);
31623129

31633130
// Then, set the root expr to redirect to the ret var
31643131
_ = try self.unify(expr_var, dispatch_ret_var, env);
3165-
std.debug.print(" ✅ Finished processing method call\n", .{});
31663132
}
31673133
} else {
31683134
// Otherwise, this is dot access on a record
@@ -4122,12 +4088,6 @@ fn checkDeferredStaticDispatchConstraints(self: *Self, env: *Env) std.mem.Alloca
41224088
var deferred_constraint_len = env.deferred_static_dispatch_constraints.items.items.len;
41234089
var deferred_constraint_index: usize = 0;
41244090

4125-
// DEBUG: Log total constraints
4126-
if (deferred_constraint_len > 0) {
4127-
std.debug.print("\n=== DEBUG: checkDeferredStaticDispatchConstraints ===\n", .{});
4128-
std.debug.print(" Total constraints to check: {d}\n", .{deferred_constraint_len});
4129-
}
4130-
41314091
while (deferred_constraint_index < deferred_constraint_len) : ({
41324092
deferred_constraint_index += 1;
41334093
deferred_constraint_len = env.deferred_static_dispatch_constraints.items.items.len;
@@ -4136,13 +4096,6 @@ fn checkDeferredStaticDispatchConstraints(self: *Self, env: *Env) std.mem.Alloca
41364096
const dispatcher_resolved = self.types.resolveVar(deferred_constraint.var_);
41374097
const dispatcher_content = dispatcher_resolved.desc.content;
41384098

4139-
// DEBUG: Log each constraint being checked
4140-
std.debug.print(" Constraint {d}: var={d}, content={s}\n", .{
4141-
deferred_constraint_index,
4142-
@intFromEnum(dispatcher_resolved.var_),
4143-
@tagName(dispatcher_content),
4144-
});
4145-
41464099
// Detect recursive constraints
41474100
// Check if this var is already in the constraint check stack
41484101
for (self.constraint_check_stack.items, 0..) |stack_var, depth| {
@@ -4249,10 +4202,6 @@ fn checkDeferredStaticDispatchConstraints(self: *Self, env: *Env) std.mem.Alloca
42494202
// .int_precision, .frac_precision, and .num_compact are all memory optimizations
42504203
// that should be treated identically to the corresponding builtin nominal types
42514204

4252-
// DEBUG: Log that we're handling a numeric type
4253-
std.debug.print("\n=== DEBUG: Handling numeric type static dispatch ===\n", .{});
4254-
std.debug.print(" Num variant: {s}\n", .{@tagName(num)});
4255-
42564205
const builtin_type_name: []const u8 = switch (num) {
42574206
.int_precision => |prec| switch (prec) {
42584207
.u8 => "U8",
@@ -4322,12 +4271,8 @@ fn checkDeferredStaticDispatchConstraints(self: *Self, env: *Env) std.mem.Alloca
43224271
);
43234272
const qualified_name_bytes = self.static_dispatch_method_name_buf.items;
43244273

4325-
// DEBUG: Log the qualified name we're looking up
4326-
std.debug.print(" Looking up method: {s}\n", .{qualified_name_bytes});
4327-
43284274
// Get the ident of this method in the builtin env
43294275
const ident_in_builtin_env = builtin_env.getIdentStoreConst().findByString(qualified_name_bytes) orelse {
4330-
std.debug.print(" ❌ Method NOT FOUND in builtin ident store!\n", .{});
43314276
try self.reportConstraintError(
43324277
deferred_constraint.var_,
43334278
constraint,
@@ -4337,11 +4282,8 @@ fn checkDeferredStaticDispatchConstraints(self: *Self, env: *Env) std.mem.Alloca
43374282
continue;
43384283
};
43394284

4340-
std.debug.print(" ✅ Found ident in builtin env: {d}\n", .{@as(u32, @bitCast(ident_in_builtin_env))});
4341-
43424285
// Get the def index in the builtin env
43434286
const node_idx_in_builtin_env = builtin_env.getExposedNodeIndexById(ident_in_builtin_env) orelse {
4344-
std.debug.print(" ❌ Method NOT EXPOSED in builtin env!\n", .{});
43454287
try self.reportConstraintError(
43464288
deferred_constraint.var_,
43474289
constraint,
@@ -4351,35 +4293,9 @@ fn checkDeferredStaticDispatchConstraints(self: *Self, env: *Env) std.mem.Alloca
43514293
continue;
43524294
};
43534295

4354-
std.debug.print(" ✅ Found node index: {d}\n", .{node_idx_in_builtin_env});
4355-
43564296
const def_idx: CIR.Def.Idx = @enumFromInt(@as(u32, @intCast(node_idx_in_builtin_env)));
43574297
const builtin_def_var: Var = ModuleEnv.varFrom(def_idx);
43584298

4359-
// DEBUG: Check the type in the builtin module BEFORE copying
4360-
const builtin_resolved = builtin_env.types.resolveVar(builtin_def_var);
4361-
std.debug.print(" BEFORE copy - builtin_def_var in Builtin module:\n", .{});
4362-
std.debug.print(" var={d}, content={s}\n", .{
4363-
@intFromEnum(builtin_resolved.var_),
4364-
@tagName(builtin_resolved.desc.content),
4365-
});
4366-
if (builtin_resolved.desc.content.unwrapFunc()) |builtin_func| {
4367-
const builtin_args = builtin_env.types.sliceVars(builtin_func.args);
4368-
std.debug.print(" function: {d} args\n", .{builtin_args.len});
4369-
for (builtin_args, 0..) |arg_var, i| {
4370-
const arg_resolved = builtin_env.types.resolveVar(arg_var);
4371-
std.debug.print(" arg[{d}] var={d}, content={s}", .{
4372-
i,
4373-
@intFromEnum(arg_resolved.var_),
4374-
@tagName(arg_resolved.desc.content),
4375-
});
4376-
if (arg_resolved.desc.content == .structure and arg_resolved.desc.content.structure == .num) {
4377-
std.debug.print(" num={s}", .{@tagName(arg_resolved.desc.content.structure.num)});
4378-
}
4379-
std.debug.print("\n", .{});
4380-
}
4381-
}
4382-
43834299
// Copy the builtin def type into the current module's type store before unifying.
43844300
// The builtin_def_var is an index in the builtin module's type store, but self.unify
43854301
// uses self.types (the current module's type store). We must translate the variable.
@@ -4399,71 +4315,8 @@ fn checkDeferredStaticDispatchConstraints(self: *Self, env: *Env) std.mem.Alloca
43994315
break :blk new_copy;
44004316
};
44014317

4402-
// DEBUG: Log what we're about to unify
4403-
const local_def_resolved = self.types.resolveVar(local_def_var);
4404-
const constraint_fn_resolved = self.types.resolveVar(constraint.fn_var);
4405-
std.debug.print(" About to unify:\n", .{});
4406-
std.debug.print(" local_def_var ({d}): {s}\n", .{
4407-
@intFromEnum(local_def_resolved.var_),
4408-
@tagName(local_def_resolved.desc.content),
4409-
});
4410-
std.debug.print(" constraint.fn_var ({d}): {s}\n", .{
4411-
@intFromEnum(constraint_fn_resolved.var_),
4412-
@tagName(constraint_fn_resolved.desc.content),
4413-
});
4414-
4415-
// DEBUG: Print function signatures if both are functions
4416-
if (local_def_resolved.desc.content.unwrapFunc()) |local_func| {
4417-
const local_args = self.types.sliceVars(local_func.args);
4418-
std.debug.print(" local_def function: {d} args, ret={d}\n", .{
4419-
local_args.len,
4420-
@intFromEnum(local_func.ret),
4421-
});
4422-
for (local_args, 0..) |arg_var, i| {
4423-
const arg_resolved = self.types.resolveVar(arg_var);
4424-
std.debug.print(" arg[{d}] var={d}, content={s}", .{
4425-
i,
4426-
@intFromEnum(arg_resolved.var_),
4427-
@tagName(arg_resolved.desc.content),
4428-
});
4429-
if (arg_resolved.desc.content == .structure) {
4430-
std.debug.print(" structure={s}", .{@tagName(arg_resolved.desc.content.structure)});
4431-
if (arg_resolved.desc.content.structure == .num) {
4432-
std.debug.print(" num={s}", .{@tagName(arg_resolved.desc.content.structure.num)});
4433-
}
4434-
}
4435-
std.debug.print("\n", .{});
4436-
}
4437-
}
4438-
if (constraint_fn_resolved.desc.content.unwrapFunc()) |constraint_func| {
4439-
const constraint_args = self.types.sliceVars(constraint_func.args);
4440-
std.debug.print(" constraint function: {d} args, ret={d}\n", .{
4441-
constraint_args.len,
4442-
@intFromEnum(constraint_func.ret),
4443-
});
4444-
for (constraint_args, 0..) |arg_var, i| {
4445-
const arg_resolved = self.types.resolveVar(arg_var);
4446-
std.debug.print(" arg[{d}] var={d}, content={s}", .{
4447-
i,
4448-
@intFromEnum(arg_resolved.var_),
4449-
@tagName(arg_resolved.desc.content),
4450-
});
4451-
if (arg_resolved.desc.content == .structure) {
4452-
std.debug.print(" structure={s}", .{@tagName(arg_resolved.desc.content.structure)});
4453-
if (arg_resolved.desc.content.structure == .num) {
4454-
std.debug.print(" num={s}", .{@tagName(arg_resolved.desc.content.structure.num)});
4455-
}
4456-
}
4457-
std.debug.print("\n", .{});
4458-
}
4459-
}
4460-
44614318
const result = try self.unify(local_def_var, constraint.fn_var, env);
4462-
std.debug.print(" Unify result: isProblem={}\n", .{result.isProblem()});
44634319
if (result.isProblem()) {
4464-
std.debug.print(" ❌❌❌ UNIFICATION FAILED\n", .{});
4465-
std.debug.print(" Error type: {s}\n", .{@tagName(result)});
4466-
std.debug.print(" Setting vars to .err\n", .{});
44674320
try self.unifyWith(deferred_constraint.var_, .err, env);
44684321
try self.unifyWith(resolved_func.ret, .err, env);
44694322
}

src/check/snapshot.zig

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,10 +1261,6 @@ pub const SnapshotWriter = struct {
12611261
fn writeNum(self: *Self, num: SnapshotNum, root_idx: SnapshotContentIdx) Allocator.Error!void {
12621262
// Match TypeWriter.zig formatting exactly - this is the source of truth
12631263

1264-
// DEBUG: Log what type of Num we're writing
1265-
std.debug.print("\n=== DEBUG writeNum ===\n", .{});
1266-
std.debug.print(" Num type: {s}\n", .{@tagName(num)});
1267-
12681264
switch (num) {
12691265
.num_poly => |sub_var| {
12701266
try self.writeWithContext(sub_var, .NumContent, root_idx);
@@ -1335,12 +1331,6 @@ pub const SnapshotWriter = struct {
13351331
// Match TypeWriter.zig formatting exactly - always print modern type names (F32, F64, Dec)
13361332
_ = num_type;
13371333

1338-
// DEBUG: Log the precision value we received
1339-
const prec_int = @intFromEnum(prec);
1340-
std.debug.print("\n=== DEBUG writeFracType ===\n", .{});
1341-
std.debug.print(" prec enum int value: {d}\n", .{prec_int});
1342-
std.debug.print(" Expected values: f32=2, f64=3, dec=4\n", .{});
1343-
13441334
_ = switch (prec) {
13451335
.f32 => try self.buf.writer().write("F32"),
13461336
.f64 => try self.buf.writer().write("F64"),

src/check/test/type_checking_integration.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ test "check type - num - float" {
5656
const source =
5757
\\10.1
5858
;
59-
try checkTypesExpr(source, .pass, "_size where [_a.from_dec_digits : _arg -> _ret, _b.from_int_digits : _arg -> _ret]");
59+
try checkTypesExpr(source, .pass, "_size where [_a.from_dec_digits : _arg -> _ret]");
6060
}
6161

6262
test "check type - num - float suffix 1" {

src/check/unify.zig

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,12 +2068,15 @@ const Unifier = struct {
20682068
.int_rigid => self.merge(vars, vars.a.desc.content),
20692069
.frac_rigid => self.merge(vars, vars.a.desc.content),
20702070

2071-
// If the variable inside a was unbound with recs, unify the reqs
2072-
.num_unbound => |a_reqs| self.merge(vars, .{ .structure = .{ .num = .{ .num_unbound = .{
2073-
.int_requirements = b_reqs.int_requirements.unify(a_reqs.int_requirements),
2074-
.frac_requirements = b_reqs.frac_requirements.unify(a_reqs.frac_requirements),
2075-
.constraints = b_reqs.constraints,
2076-
} } } }),
2071+
// If the variable inside a was unbound with reqs, unify the reqs and keep wrapped in num_poly
2072+
.num_unbound => |a_reqs| {
2073+
const merged_unbound = self.fresh(vars, .{ .structure = .{ .num = .{ .num_unbound = .{
2074+
.int_requirements = b_reqs.int_requirements.unify(a_reqs.int_requirements),
2075+
.frac_requirements = b_reqs.frac_requirements.unify(a_reqs.frac_requirements),
2076+
.constraints = b_reqs.constraints,
2077+
} } } }) catch return Error.AllocatorError;
2078+
self.merge(vars, .{ .structure = .{ .num = .{ .num_poly = merged_unbound } } });
2079+
},
20772080
.frac_unbound => |a_reqs| {
20782081
const poly_unbound = self.fresh(vars, .{ .structure = .{
20792082
.num = .{ .frac_unbound = b_reqs.frac_requirements.unify(a_reqs) },
@@ -2144,12 +2147,15 @@ const Unifier = struct {
21442147
.int_rigid => self.merge(vars, vars.b.desc.content),
21452148
.frac_rigid => self.merge(vars, vars.b.desc.content),
21462149

2147-
// If the variable inside a was unbound with recs, unify the reqs
2148-
.num_unbound => |b_reqs| self.merge(vars, .{ .structure = .{ .num = .{ .num_unbound = .{
2149-
.int_requirements = a_reqs.int_requirements.unify(b_reqs.int_requirements),
2150-
.frac_requirements = a_reqs.frac_requirements.unify(b_reqs.frac_requirements),
2151-
.constraints = a_reqs.constraints,
2152-
} } } }),
2150+
// If the variable inside b was unbound with reqs, unify the reqs and keep wrapped in num_poly
2151+
.num_unbound => |b_reqs| {
2152+
const merged_unbound = self.fresh(vars, .{ .structure = .{ .num = .{ .num_unbound = .{
2153+
.int_requirements = a_reqs.int_requirements.unify(b_reqs.int_requirements),
2154+
.frac_requirements = a_reqs.frac_requirements.unify(b_reqs.frac_requirements),
2155+
.constraints = a_reqs.constraints,
2156+
} } } }) catch return Error.AllocatorError;
2157+
self.merge(vars, .{ .structure = .{ .num = .{ .num_poly = merged_unbound } } });
2158+
},
21532159
.frac_unbound => |b_reqs| {
21542160
const poly_unbound = self.fresh(vars, .{ .structure = .{
21552161
.num = .{ .frac_unbound = a_reqs.frac_requirements.unify(b_reqs) },

src/layout/store.zig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -825,11 +825,7 @@ pub const Store = struct {
825825
unresolved_var: Var,
826826
type_scope: *const TypeScope,
827827
) (LayoutError || std.mem.Allocator.Error)!Idx {
828-
std.debug.print("\n=== DEBUG: addTypeVar called ===\n", .{});
829-
std.debug.print(" unresolved_var: {d}\n", .{@intFromEnum(unresolved_var)});
830828
var current = self.types_store.resolveVar(unresolved_var);
831-
std.debug.print(" resolved to var: {d}\n", .{@intFromEnum(current.var_)});
832-
std.debug.print(" content tag: {s}\n", .{@tagName(current.desc.content)});
833829

834830
// If we've already seen this var, return the layout we resolved it to.
835831
if (self.layouts_by_var.get(current.var_)) |cached_idx| {
@@ -1454,10 +1450,6 @@ pub const Store = struct {
14541450
continue;
14551451
},
14561452
.err => {
1457-
std.debug.print("\n=== DEBUG: Hit .err in addTypeVar ===\n", .{});
1458-
std.debug.print(" Var number: {d}\n", .{@intFromEnum(current.var_)});
1459-
std.debug.print(" Type desc content: .err\n", .{});
1460-
std.debug.print(" Original unresolved var: {d}\n", .{@intFromEnum(unresolved_var)});
14611453
return LayoutError.TypeContainedMismatch;
14621454
},
14631455
};

0 commit comments

Comments
 (0)