Files
hakorune/tools
nyash-codex 9f2c791f2a fix(json_parser): Eliminate _parse_number() infinite loop with flat control flow
Root cause: Nested-if-in-loop pattern triggered MIR compiler bug
- `if parsing_done == 1 { break }` inside loop caused infinite execution
- Flag variable approach created 2-level nesting that MIR couldn't handle

Fix: Refactored to flat control flow
- Removed `parsing_done` flag variable
- Inverted condition: check exit first (`digit_pos < 0 → break`)
- Direct break without nesting
- Moved `digits` constant outside loop (optimization)

Result:
- Lines: 28 → 15 (-46% complexity)
- Nesting: 2 levels → 1 level
- MIR-safe: No nested-if-in-loop pattern

This unblocks Phase 161-2 full MIR JSON parsing (rep1_if_simple.mir.json 8.5KB)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 20:00:27 +09:00
..