**Problem**: is_parameter() was too simple, checking only ValueId which changes
through copies/PHIs. This caused parameters like 'data' to be misclassified as
carriers, leading to incorrect PHI construction.
**Solution**: Track original parameter names at function entry.
**Changes**:
1. **Added function_param_names field** (builder.rs):
- HashSet<String> to track original parameter names
- Populated in lower_static_method_as_function()
- Cleared and repopulated for each new function
2. **Improved is_parameter()** (loop_builder.rs):
- Check name against function_param_names instead of ValueId
- More reliable than checking func.params (ValueIds change)
- __pin$*$@* variables correctly classified as carriers
- Added debug logging with NYASH_LOOPFORM_DEBUG
3. **Enhanced debug output** (loopform_builder.rs):
- Show carrier/pinned classification during prepare_structure()
- Show variable_map state after emit_header_phis()
**Test Results**:
- ✅ 'args' correctly identified as parameter (was working)
- ✅ 'data' now correctly identified as parameter (was broken)
- ✅ __pin variables correctly classified as carriers
- ✅ PHI values allocated and variable_map updated correctly
- ⚠️ ValueId undefined errors persist (separate issue)
**Remaining Issue**:
ValueId(10) undefined error suggests PHI visibility problem or VM verification
issue. Needs further investigation of emit_phi_at_block_start() or VM executor.
**Backward Compatibility**:
- Flag OFF: 100% existing behavior preserved (legacy path unchanged)
- Feature-flagged with NYASH_LOOPFORM_PHI_V2=1
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>