diff --git a/src/mir/builder.rs b/src/mir/builder.rs index 36c26387..6e630dd7 100644 --- a/src/mir/builder.rs +++ b/src/mir/builder.rs @@ -487,12 +487,18 @@ impl MirBuilder { var_name: String, value: ASTNode, ) -> Result { - let raw_value_id = self.build_expression(value)?; - // Correctness-first: assignment results may be used across control-flow joins. - // Pin to a slot so the value has a block-local def and participates in PHI merges. - let value_id = self - .pin_to_slot(raw_value_id, "@assign") - .unwrap_or(raw_value_id); + let value_id = self.build_expression(value)?; + + // Step 5-5-E: FIX variable map corruption bug + // REMOVED pin_to_slot() call - it was causing __pin$ temporaries to overwrite + // real variable names in the variable map. + // + // Root cause: pin_to_slot(raw_value_id, "@assign") would sometimes return + // a ValueId from a previous __pin$ temporary (e.g., __pin$767$@binop_lhs), + // causing variable_map["m"] to point to the wrong ValueId. + // + // SSA + PHI merges work correctly without explicit pinning here. + // The expression building already creates necessary temporaries. // In SSA form, each assignment creates a new value self.variable_map.insert(var_name.clone(), value_id);