js-on-sx: object literal __proto__ + try/catch error wrapping
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 36s

This commit is contained in:
2026-05-08 22:13:17 +00:00
parent 0d9c45176b
commit a1030dce5d
3 changed files with 58 additions and 2 deletions

View File

@@ -991,6 +991,34 @@
(define SuppressedError :js-undefined)
(define
js-str-startswith?
(fn
(s prefix)
(cond
((< (len s) (len prefix)) false)
(else (= (js-string-slice s 0 (len prefix)) prefix)))))
(define
js-wrap-exn
(fn
(e)
(cond
((not (= (type-of e) "string")) e)
((js-str-startswith? e "Undefined symbol:")
(js-new-call ReferenceError (js-args e)))
((js-str-startswith? e "TypeError:")
(js-new-call TypeError (js-args (js-string-slice e 11 (len e)))))
((js-str-startswith? e "RangeError:")
(js-new-call RangeError (js-args (js-string-slice e 12 (len e)))))
((js-str-startswith? e "SyntaxError:")
(js-new-call SyntaxError (js-args (js-string-slice e 13 (len e)))))
((js-str-startswith? e "ReferenceError:")
(js-new-call ReferenceError (js-args (js-string-slice e 16 (len e)))))
((js-str-startswith? e "URIError:")
(js-new-call URIError (js-args (js-string-slice e 10 (len e)))))
(else e))))
(define
js-date-from-one
(fn
@@ -3194,7 +3222,12 @@
(define
js-make-obj
(fn () (let ((d (dict))) (begin (dict-set! d "__js_order__" (list)) d))))
(fn ()
(let ((d (dict)))
(begin
(dict-set! d "__js_order__" (list))
(dict-set! d "__proto__" (get Object "prototype"))
d))))
(define
js-obj-order-add!

View File

@@ -1407,7 +1407,28 @@
(let
((body-tr (js-transpile body)))
(let
((with-catch (cond ((= catch-part nil) body-tr) (else (let ((pname (nth catch-part 0)) (cbody (nth catch-part 1))) (list (js-sym "guard") (list (if (= pname nil) (js-sym "__exc__") (js-sym pname)) (list (js-sym "else") (js-transpile cbody))) body-tr))))))
((with-catch
(cond
((= catch-part nil) body-tr)
(else
(let
((pname (nth catch-part 0))
(cbody (nth catch-part 1))
(raw-sym (js-sym "__raw_exc__")))
(list
(js-sym "guard")
(list
raw-sym
(list
(js-sym "else")
(cond
((= pname nil) (js-transpile cbody))
(else
(list
(js-sym "let")
(list (list (js-sym pname) (list (js-sym "js-wrap-exn") raw-sym)))
(js-transpile cbody))))))
body-tr))))))
(cond
((= finally-part nil) with-catch)
(else