Dedup the two .method dot-dispatch arms into one dispatch-member (jolt-eos3)

eval-dot copy-pasted its entire dispatch chain across the (. obj method args...)
and (. obj member) forms — string/number/object/tagged-shim lookup duplicated,
hand-synced on every interop change. Extract one dispatch-member that takes the
evaluated args plus a has-args flag. The shared head (string/number/object/
tagged) is single-sourced; the genuinely divergent tails (call form: record →
native field → coll-interop(args); bare form: zero-arg coll-interop → field /
zero-arg method) stay branched on has-args. The guards that differed between the
arms (object-methods checks table? only; tagged dispatch checks table-or-struct;
bare-form tagged dispatch requires the member present) are preserved verbatim,
keyed off has-args, so behavior is identical.

Adds a "dot dispatch arms" spec locking the divergent cases: zero-arg vs
with-arg coll-interop, record/deftype zero-arg vs with-args methods, -field
access. Full gate green.
This commit is contained in:
Yogthos 2026-06-15 04:35:52 -04:00
parent 6c0142e625
commit 0406b315a9
2 changed files with 132 additions and 105 deletions

View file

@ -9,6 +9,25 @@
["field access .-" "41" "(.-value {:value 41})"]
["dot field keyword" "41" "(. {:value 41} :value)"])
# Both `.` arms share one dispatch-member helper (jolt-eos3). These rows lock the
# behaviors where the call form (args) and the bare form (zero-arg) diverge in
# their tails: zero-arg coll-interop vs with-arg coll-interop, and record/deftype
# zero-arg methods vs methods-with-args vs `-field` field access.
(defspec "interop / dot dispatch arms"
["zero-arg coll-interop .count" "3" "(.count [1 2 3])"]
["zero-arg coll-interop .seq" "[1 2]" "(.seq [1 2])"]
["explicit dot zero-arg interop" "3" "(. [1 2 3] count)"]
["with-arg coll-interop .nth" "2" "(.nth [1 2 3] 1)"]
["record zero-arg method" "10"
"(do (defprotocol Pd (gm [this])) (defrecord Rd [x] Pd (gm [this] (* 2 x))) (.gm (->Rd 5)))"]
["record method with args" "15"
"(do (defprotocol Pa (am [this y])) (defrecord Ra [x] Pa (am [this y] (+ x y))) (.am (->Ra 5) 10))"]
["deftype method with args" "7"
"(do (defprotocol Pq (qq [this y])) (deftype Tq [x] Pq (qq [this y] (+ x y))) (.qq (Tq. 3) 4))"]
["record -field is field access" "7"
"(do (defrecord Rf [x]) (.-x (->Rf 7)))"]
["object-method with args .equals" "true" "(.equals \"a\" \"a\")"])
# The `janet` namespace segment is the explicit Janet-stdlib bridge added for
# the networking layer (and used by jolt.nrepl). `janet/<name>` resolves a Janet
# root binding; `janet.<module>/<name>` resolves a module binding. The boundary