macro(match): add guard-literal-OR smoke (AST no PeekExpr + VM output); stabilize smoke robustness; LLVM PHI hygiene now passing for assign/print/match_literal

This commit is contained in:
Selfhosting Dev
2025-09-20 05:34:23 +09:00
parent 14122c1e55
commit 5a2f04be95
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,8 @@
local d = 2
local r = match d {
1 if (1 < 2) => 10
2 if (2 < 3) => 20
_ => 30
}
print(r)

View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -u
root=$(cd "$(dirname "$0")"/../../../.. && pwd)
bin="$root/target/release/nyash"
src="apps/tests/macro/match/guard_literal_or.nyash"
if [ ! -x "$bin" ]; then
echo "nyash binary not found at $bin; build first (cargo build --release)" >&2
exit 1
fi
export NYASH_MACRO_ENABLE=1
# 1) AST expanded (no PeekExpr)
out_ast=$("$bin" --dump-expanded-ast-json "$src")
if [[ "$out_ast" == *'"kind":"PeekExpr"'* ]]; then
echo "[FAIL] Expanded AST still contains PeekExpr for guard-literal-or" >&2
exit 2
fi
# 2) Runtime output check via VM
export NYASH_VM_USE_PY=1
out_run=$("$bin" --backend vm "$src" | tr -d '\r')
# allow trailing newline to be trimmed by command substitution
if [ "$out_run" != "20" ] && [ "$out_run" != $'20\n' ]; then
echo "[FAIL] VM run unexpected output. Got:" >&2
printf '%s\n' "$out_run" >&2
exit 2
fi
echo "[OK] match guard literal OR smoke passed"