fix(mir): remove ValueId reset in function lowering - resolve ValueId undefined errors

Problem: ValueId(17/31/46615) undefined errors during VM execution
Root cause: value_gen.reset() in lower_method_as_function and
  lower_static_method_as_function caused ValueId reuse across
  multiple functions, leading to value_types HashMap corruption

Solution: Remove 6 lines (2 sets of save/reset/restore logic)
  - Set 1 (lower_method_as_function): Lines 896-897, 951
  - Set 2 (lower_static_method_as_function): Lines 980-981, 1037

Impact: Maintains global ValueId uniqueness across all functions
  - No side effects (reset logic was unnecessary)
  - Fixes ParserBox and complex static box execution

Test: /tmp/test_parserbox.hako now progresses past ValueId errors
  - Previous: Invalid value: use of undefined value ValueId(17)
  - After: Different error (Box type registration), confirming fix

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-01 12:07:22 +09:00
parent d7a406751a
commit e67f22ba5c

View File

@ -893,8 +893,6 @@ impl super::MirBuilder {
let saved_function = self.current_function.take();
let saved_block = self.current_block.take();
let saved_var_map = std::mem::take(&mut self.variable_map);
let saved_value_gen = self.value_gen.clone();
self.value_gen.reset();
self.current_function = Some(function);
self.current_block = Some(entry);
self.ensure_block_exists(entry)?;
@ -950,7 +948,6 @@ impl super::MirBuilder {
self.current_function = saved_function;
self.current_block = saved_block;
self.variable_map = saved_var_map;
self.value_gen = saved_value_gen;
Ok(())
}
@ -980,8 +977,6 @@ impl super::MirBuilder {
let saved_function = self.current_function.take();
let saved_block = self.current_block.take();
let saved_var_map = std::mem::take(&mut self.variable_map);
let saved_value_gen = self.value_gen.clone();
self.value_gen.reset();
self.current_function = Some(function);
self.current_block = Some(entry);
self.ensure_block_exists(entry)?;
@ -1039,7 +1034,6 @@ impl super::MirBuilder {
self.current_function = saved_function;
self.current_block = saved_block;
self.variable_map = saved_var_map;
self.value_gen = saved_value_gen;
// Restore static box context
self.current_static_box = saved_static_ctx;
Ok(())