@@ -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 }
0 commit comments