diff --git a/lang/src/compiler/entry/bundle_resolver.hako b/lang/src/compiler/entry/bundle_resolver.hako index c5570c30..72c08249 100644 --- a/lang/src/compiler/entry/bundle_resolver.hako +++ b/lang/src/compiler/entry/bundle_resolver.hako @@ -22,16 +22,14 @@ static box BundleResolver { local pos = -1 local k = 0 loop(k < seg.length()) { if seg.substring(k,k+1) == ":" { pos = k break } k = k + 1 } - if pos >= 0 { - local name = seg.substring(0, pos) - local code = seg.substring(pos+1, seg.length()) - if name != "" && code != "" { - if bundle_names == null { bundle_names = new ArrayBox() } - if bundle_mod_srcs == null { bundle_mod_srcs = new ArrayBox() } - bundle_names.push(name) - bundle_mod_srcs.push(code) - } - } + if pos < 0 { print("[bundle/alias-table/bad] " + seg) return null } + local name = seg.substring(0, pos) + local code = seg.substring(pos+1, seg.length()) + if name == "" || code == "" { print("[bundle/alias-table/bad] " + seg) return null } + if bundle_names == null { bundle_names = new ArrayBox() } + if bundle_mod_srcs == null { bundle_mod_srcs = new ArrayBox() } + bundle_names.push(name) + bundle_mod_srcs.push(code) } if j < 0 { break } i = j + 3 diff --git a/tools/smokes/v2/profiles/quick/core/bridge/canonicalize_closure_missing_func_negative_vm.sh b/tools/smokes/v2/profiles/quick/core/bridge/canonicalize_closure_missing_func_negative_vm.sh new file mode 100644 index 00000000..b0e9c924 --- /dev/null +++ b/tools/smokes/v2/profiles/quick/core/bridge/canonicalize_closure_missing_func_negative_vm.sh @@ -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 +