js-on-sx: Error.isError + [[ErrorData]] slot + verifyEqualTo
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 37s

This commit is contained in:
2026-05-08 20:55:13 +00:00
parent ecae58316f
commit d8b8de6195
3 changed files with 50 additions and 7 deletions

View File

@@ -834,10 +834,36 @@
(= (len args) 0)
""
(js-to-string (nth args 0))))
(dict-set! this "name" "Error"))
(dict-set! this "name" "Error")
(dict-set! this "__js_error_data__" true))
nil)
this))))
(define
js-error-is-error
(fn
(&rest args)
(cond
((= (len args) 0) false)
(else
(let
((v (nth args 0)))
(and
(= (type-of v) "dict")
(or
(contains? (keys v) "__js_error_data__")
(js-error-proto-walk? v))))))))
(define
js-error-proto-walk?
(fn
(v)
(cond
((not (= (type-of v) "dict")) false)
((contains? (keys v) "__js_error_data__") true)
((not (contains? (keys v) "__proto__")) false)
(else (js-error-proto-walk? (get v "__proto__"))))))
;; ── Math object ───────────────────────────────────────────────────
(define
@@ -857,7 +883,8 @@
(= (len args) 0)
""
(js-to-string (nth args 0))))
(dict-set! this "name" "TypeError"))
(dict-set! this "name" "TypeError")
(dict-set! this "__js_error_data__" true))
nil)
this))))
(define
@@ -877,7 +904,8 @@
(= (len args) 0)
""
(js-to-string (nth args 0))))
(dict-set! this "name" "RangeError"))
(dict-set! this "name" "RangeError")
(dict-set! this "__js_error_data__" true))
nil)
this))))
(define
@@ -897,7 +925,8 @@
(= (len args) 0)
""
(js-to-string (nth args 0))))
(dict-set! this "name" "SyntaxError"))
(dict-set! this "name" "SyntaxError")
(dict-set! this "__js_error_data__" true))
nil)
this))))
(define
@@ -917,7 +946,8 @@
(= (len args) 0)
""
(js-to-string (nth args 0))))
(dict-set! this "name" "ReferenceError"))
(dict-set! this "name" "ReferenceError")
(dict-set! this "__js_error_data__" true))
nil)
this))))
(define
@@ -935,7 +965,8 @@
this
"message"
(if (empty? args) "" (js-to-string (nth args 0))))
(dict-set! this "name" "URIError")))
(dict-set! this "name" "URIError")
(dict-set! this "__js_error_data__" true)))
this))))
(define
EvalError
@@ -952,8 +983,13 @@
this
"message"
(if (empty? args) "" (js-to-string (nth args 0))))
(dict-set! this "name" "EvalError")))
(dict-set! this "name" "EvalError")
(dict-set! this "__js_error_data__" true)))
this))))
(define AggregateError :js-undefined)
(define SuppressedError :js-undefined)
(define
js-function?
(fn
@@ -2965,6 +3001,8 @@
(js-dict-get-walk obj (js-to-string key)))
((and (= obj Promise) (dict-has? __js_promise_statics__ (js-to-string key)))
(get __js_promise_statics__ (js-to-string key)))
((and (= obj Error) (= (js-to-string key) "isError"))
js-error-is-error)
((and (js-function? obj) (or (= key "prototype") (= key "name") (= key "length") (= key "call") (= key "apply") (= key "bind") (= key "constructor")))
(cond
((= key "prototype") (js-get-ctor-proto obj))

View File

@@ -134,6 +134,9 @@ var verifyProperty = function (obj, name, desc, opts) {
}
};
var verifyPrimordialProperty = verifyProperty;
var verifyEqualTo = function (obj, name, value) {
assert.sameValue(obj[name], value, name + " equals");
};
var verifyNotEnumerable = function (o, n, v, w, x) { };
var verifyNotWritable = function (o, n, v, w, x) { };
var verifyNotConfigurable = function (o, n, v, w, x) { };