Stage‑B alias/table negatives + Bridge v1 Closure negatives + docs sweep (minor)

- BundleResolver: fail-fast with tag on malformed alias table entries ([bundle/alias-table/bad] <entry>)
- Add opt-in negatives:
  - canonicalize_closure_captures_negative_vm (captures wrong types)
  - canonicalize_closure_missing_func_negative_vm (missing func in Closure)
  - stageb_bundle_alias_table_bad_vm (malformed alias table)
- README minor replacements to  (residuals)

All new tests are opt-in; quick remains green.
This commit is contained in:
nyash-codex
2025-11-02 17:57:41 +09:00
parent b988d309f0
commit ddf736ddef
2 changed files with 52 additions and 10 deletions

View File

@ -22,16 +22,14 @@ static box BundleResolver {
local pos = -1 local pos = -1
local k = 0 local k = 0
loop(k < seg.length()) { if seg.substring(k,k+1) == ":" { pos = k break } k = k + 1 } loop(k < seg.length()) { if seg.substring(k,k+1) == ":" { pos = k break } k = k + 1 }
if pos >= 0 { if pos < 0 { print("[bundle/alias-table/bad] " + seg) return null }
local name = seg.substring(0, pos) local name = seg.substring(0, pos)
local code = seg.substring(pos+1, seg.length()) local code = seg.substring(pos+1, seg.length())
if name != "" && code != "" { if name == "" || code == "" { print("[bundle/alias-table/bad] " + seg) return null }
if bundle_names == null { bundle_names = new ArrayBox() } if bundle_names == null { bundle_names = new ArrayBox() }
if bundle_mod_srcs == null { bundle_mod_srcs = new ArrayBox() } if bundle_mod_srcs == null { bundle_mod_srcs = new ArrayBox() }
bundle_names.push(name) bundle_names.push(name)
bundle_mod_srcs.push(code) bundle_mod_srcs.push(code)
}
}
} }
if j < 0 { break } if j < 0 { break }
i = j + 3 i = j + 3

View File

@ -0,0 +1,44 @@
#!/bin/bash
# canonicalize_closure_missing_func_negative_vm.sh — v1 bridge Closure missing func should fail
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then
ROOT="$ROOT_GIT"
else
ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"
fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"
require_env || exit 2
# Opt-in with SMOKES_ENABLE_BRIDGE_CLOSURE=1
if [ "${SMOKES_ENABLE_BRIDGE_CLOSURE:-0}" != "1" ]; then
test_skip canonicalize_closure_missing_func_negative_vm "opt-in (SMOKES_ENABLE_BRIDGE_CLOSURE=1)"
exit 0
fi
json_path="/tmp/ny_v1_closure_caps_missing_func_$$.json"
cat >"$json_path" <<'JSON'
{"schema_version":"1.0","functions":[{"name":"main","blocks":[{"id":0,"instructions":[
{"op":"mir_call","dst":3,
"callee":{"type":"Closure","captures":[1,2]},
"args":[1,2]},
{"op":"ret"}
]}]}]}
JSON
set +e
HAKO_NYVM_V1_DOWNCONVERT=1 "$NYASH_BIN" --json-file "$json_path" >/dev/null 2>&1
rc=$?
set -e
rm -f "$json_path"
if [ "$rc" != 0 ]; then
echo "[PASS] canonicalize_closure_missing_func_negative_vm"
exit 0
else
echo "[FAIL] canonicalize_closure_missing_func_negative_vm (unexpected rc=0)" >&2
exit 1
fi