loopform(hints): detect up to 2 assigned vars in loop body (no break/continue) and emit LoopCarrier hint; add smoke for two-vars case
This commit is contained in:
25
tools/test/smoke/mir/hints_loop_carrier_two_vars_smoke.sh
Normal file
25
tools/test/smoke/mir/hints_loop_carrier_two_vars_smoke.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")"/../../../.. && pwd)
|
||||
bin="$root/target/release/nyash"
|
||||
src="apps/tests/macro/loopform/two_vars.nyash"
|
||||
|
||||
if [ ! -x "$bin" ]; then
|
||||
echo "nyash binary not found at $bin; build first (cargo build --release)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export NYASH_MIR_TRACE_HINTS=1
|
||||
|
||||
out=$({ "$bin" --backend vm "$src" 1>/dev/null; } 2>&1 || true)
|
||||
|
||||
# Check the LoopCarrier hint contains both variable names (order-agnostic)
|
||||
echo "$out" | rg -q "\[mir\]\[hint\] LoopCarrier\((i,sum|sum,i)\)" || {
|
||||
echo "[FAIL] missing LoopCarrier(i,sum) hint" >&2
|
||||
printf '%s\n' "$out" | tail -n 80 >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
echo "[OK] MIR hints LoopCarrier(two vars) trace smoke passed"
|
||||
|
||||
Reference in New Issue
Block a user