fix(mir): fix else block scope bug - PHI materialization order
Root Cause: - Else blocks were not propagating variable assignments to outer scope - Bug 1 (if_form.rs): PHI materialization happened before variable_map reset, causing PHI nodes to be lost - Bug 2 (phi.rs): Variable merge didn't check if else branch modified variables Changes: - src/mir/builder/if_form.rs:93-127 - Reordered: reset variable_map BEFORE materializing PHI nodes - Now matches then-branch pattern (reset → materialize → execute) - Applied to both "else" and "no else" branches for consistency - src/mir/builder/phi.rs:137-154 - Added else_modified_var check to detect variable modifications - Use modified value from else_var_map_end_opt when available - Fall back to pre-if value only when truly not modified Test Results: ✅ Simple block: { x=42 } → 42 ✅ If block: if 1 { x=42 } → 42 ✅ Else block: if 0 { x=99 } else { x=42 } → 42 (FIXED!) ✅ Stage-B body extraction: "return 42" correctly extracted (was null) Impact: - Else block variable assignments now work correctly - Stage-B compiler body extraction restored - Selfhost builder path can now function - Foundation for Phase 21.x progress 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -4,6 +4,14 @@
|
||||
NYASH_ENABLE_USING = "1"
|
||||
# Enable dev sugar preexpand for @ local alias (line-head) during parsing
|
||||
NYASH_DEV_AT_LOCAL = "1"
|
||||
# AOT prep/fast-path defaults (dev/quick friendly; override with NYASH_SKIP_TOML_ENV=1)
|
||||
# Collections hot path rewrite (Array/Map boxcall→externcall)
|
||||
NYASH_AOT_COLLECTIONS_HOT = "1"
|
||||
# Integer fast paths and simple loop hoist (safe CFG-invariant opts)
|
||||
NYASH_LLVM_FAST = "1"
|
||||
NYASH_MIR_LOOP_HOIST = "1"
|
||||
# Map key mode heuristic (h/hh chosen automatically by linearity)
|
||||
NYASH_AOT_MAP_KEY_MODE = "auto"
|
||||
|
||||
[using]
|
||||
paths = ["apps", "lib", ".", "lang/src"]
|
||||
|
||||
Reference in New Issue
Block a user