@@ -235,7 +235,48 @@ racket "$RT" --emit-edn "$W/rq.bclj" 2>/dev/null > "$W/rq.edn"
235235bb -cp " $FRAM_OUT " " $RES " rename base root rq " $W /rq.edn" 2> /dev/null
236236chk " reader ~ unquote inside quote escapes + renames" " grep -qF '(root y)' <<<\"\$ (racket \" $RT \" --render /tmp/resolved-rq.bclj.edn 2>/dev/null)\" "
237237
238+ # --- 12. match patterns + typed let + map->/accessor factories (adversarial sweep #6) -
239+ echo " --- 12. match-pattern scope + typed let + map->/accessor cascade ---"
240+ # 12a. match constructor pattern renames with the type; match-local not over-renamed
241+ cat > " $W /mt.bclj" << 'EOF '
242+ #lang beagle/clj
243+ (ns mt)
244+ (defrecord Ok [(value :- Int)])
245+ (defrecord Err [(error :- Int)])
246+ (defunion Result Ok Err)
247+ (def src :- Int 100)
248+ (defn f [r :- Result] :- Int (match r [(Ok v) (+ v src)] [(Err e) e]))
249+ EOF
250+ racket " $RT " --emit-edn " $W /mt.bclj" 2> /dev/null > " $W /mt.edn"
251+ bb -cp " $FRAM_OUT " " $RES " rename Ok Good mt " $W /mt.edn" 2> /dev/null
252+ chk " match pattern (Ok v) renames with the type" " grep -qF '[(Good v)' <<<\"\$ (racket \" $RT \" --render /tmp/resolved-mt.bclj.edn 2>/dev/null)\" "
253+ # 12b. renaming a def to a match-bound var name is REFUSED (capture)
254+ if bb -cp " $FRAM_OUT " " $RES " rename src v mt " $W /mt.edn" > /dev/null 2>&1 ; then
255+ echo " FAIL match-pattern capture not refused" ; fail=1
256+ else echo " PASS match-pattern capture refused" ; fi
257+ # 12c. renaming the def does NOT touch the match-bound local of a different name
258+ bb -cp " $FRAM_OUT " " $RES " rename src total mt " $W /mt.edn" 2> /dev/null
259+ chk " match-local 'v' untouched when def renamed" " grep -qF '(+ v total)' <<<\"\$ (racket \" $RT \" --render /tmp/resolved-mt.bclj.edn 2>/dev/null)\" "
260+ # 12d. typed let binding annotation cascades on a type rename
261+ printf ' #lang beagle/clj\n(ns tl)\n(defrecord Foo [(v :- Int)])\n(defn g [p :- Foo] :- Foo (let [q :- Foo p] q))\n' > " $W /tl.bclj"
262+ racket " $RT " --emit-edn " $W /tl.bclj" 2> /dev/null > " $W /tl.edn"
263+ bb -cp " $FRAM_OUT " " $RES " rename Foo Bar tl " $W /tl.edn" 2> /dev/null
264+ chk " typed let binding (q :- Foo) cascades" " grep -qF '(let [q :- Bar p]' <<<\"\$ (racket \" $RT \" --render /tmp/resolved-tl.bclj.edn 2>/dev/null)\" "
265+ # 12e. map-> factory AND synthesized field accessor carry the rename
266+ cat > " $W /fa.bclj" << 'EOF '
267+ #lang beagle/clj
268+ (ns fa)
269+ (defrecord Point [(x :- Int) (y :- Int)])
270+ (defn a [p :- Point] :- Int (point-x p))
271+ (defn c [] :- Point (map->Point {:x 1 :y 2}))
272+ EOF
273+ racket " $RT " --emit-edn " $W /fa.bclj" 2> /dev/null > " $W /fa.edn"
274+ bb -cp " $FRAM_OUT " " $RES " rename Point Vertex fa " $W /fa.edn" 2> /dev/null
275+ fa=" $( racket " $RT " --render /tmp/resolved-fa.bclj.edn 2> /dev/null) "
276+ chk " field accessor point-x -> vertex-x" " grep -qF '(vertex-x p)' <<<\"\$ fa\" "
277+ chk " map->Point -> map->Vertex" " grep -qF '(map->Vertex' <<<\"\$ fa\" "
278+
238279echo
239280if [ " $fail " = 0 ]; then
240- echo " RESULT: PASS — one engine: collision/shadowing/cross-module/ types/sequential/quasiquote/idioms, recompiles."
281+ echo " RESULT: PASS — one engine: scope/ types/sequential/quasiquote/idioms/match/factories/accessors , recompiles."
241282else echo " RESULT: FAIL" ; exit 1; fi
0 commit comments