Fix transpiler call-expression bug: ((get d k) args) now emits function call

The transpiler treated any list with a non-symbol head as a data list,
emitting [head, args] as a JS array literal. When head is a sub-expression
(another call), it should emit (head)(args) — a function call.

This fixes the custom special forms dispatch in transpiled code:
  Before: [get(_customSpecialForms, name), args, env]  (array — broken)
  After:  (get(_customSpecialForms, name))(args, env)   (call — correct)

Also fixes IIFE patterns: ((fn (x) body) arg) now emits
  (function(x) { ... })(arg) instead of [function(x){...}, arg]

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 18:24:45 +00:00
parent 945b4c1dd7
commit 2d8741779e
2 changed files with 15 additions and 5 deletions

View File

@@ -932,8 +932,11 @@
(let ((head (first expr))
(args (rest expr)))
(if (not (= (type-of head) "symbol"))
;; Data list — not a function call
(str "[" (join ", " (map js-expr expr)) "]")
(if (= (type-of head) "list")
;; Head is a sub-expression (call) — emit as function call: (head)(args)
(str "(" (js-expr head) ")(" (join ", " (map js-expr args)) ")")
;; Data list — not a function call
(str "[" (join ", " (map js-expr expr)) "]"))
(let ((op (symbol-name head)))
(cond
;; fn/lambda