From 3e1bca543518d1fabb332fef5926acf350a4f311 Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 24 Apr 2026 09:21:14 +0000 Subject: [PATCH] js-on-sx: Object.prototype has hasOwnProperty/isPrototypeOf/toString/valueOf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before, Object.prototype was {} — tests writing Object.prototype.hasOwnProperty.call(o, 'x') failed with 'TypeError: call is not a function' because hasOwnProperty was undefined on the prototype. Now Object.prototype.hasOwnProperty / .isPrototypeOf / .propertyIsEnumerable / .toString / .toLocaleString / .valueOf all exist. They dispatch on (js-this) so Array.prototype.X.call-style calls work. Unblocks String.prototype.* tests that set up '__instance = new Object(true)' and then probe __instance.hasOwnProperty. Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/js/runtime.sx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/js/runtime.sx b/lib/js/runtime.sx index 8772d1e2..ba77a18f 100644 --- a/lib/js/runtime.sx +++ b/lib/js/runtime.sx @@ -2567,7 +2567,7 @@ (and (>= idx 0) (< idx (len o)) (integer? idx)))) (else false)))) -(define Object {:entries js-object-entries :defineProperties js-object-define-properties :__callable__ (fn (&rest args) (cond ((= (len args) 0) (dict)) (else (nth args 0)))) :preventExtensions js-object-prevent-extensions :prototype {} :values js-object-values :hasOwn js-object-has-own :freeze js-object-freeze :assign js-object-assign :isFrozen js-object-is-frozen :getOwnPropertyDescriptor js-object-get-own-property-descriptor :fromEntries js-object-from-entries :defineProperty js-object-define-property :setPrototypeOf js-object-set-prototype-of :getOwnPropertyNames js-object-get-own-property-names :getOwnPropertyDescriptors js-object-get-own-property-descriptors :create js-object-create :isExtensible js-object-is-extensible :is js-object-is :keys js-object-keys :getPrototypeOf js-object-get-prototype-of :isSealed js-object-is-sealed :seal js-object-seal}) +(define Object {:entries js-object-entries :defineProperties js-object-define-properties :__callable__ (fn (&rest args) (cond ((= (len args) 0) (dict)) (else (nth args 0)))) :preventExtensions js-object-prevent-extensions :prototype {:valueOf (fn () (js-this)) :propertyIsEnumerable (fn (k) (let ((o (js-this))) (js-object-has-own o k))) :isPrototypeOf (fn (o) (let ((this-val (js-this))) (cond ((not (dict? o)) false) (else (let ((proto (if (contains? (keys o) "__proto__") (get o "__proto__") nil))) (cond ((= proto this-val) true) ((= proto nil) false) (else ((get (get Object "prototype") "isPrototypeOf") proto)))))))) :toString (fn () "[object Object]") :hasOwnProperty (fn (k) (let ((o (js-this))) (js-object-has-own o k))) :toLocaleString (fn () "[object Object]")} :values js-object-values :hasOwn js-object-has-own :freeze js-object-freeze :assign js-object-assign :isFrozen js-object-is-frozen :getOwnPropertyDescriptor js-object-get-own-property-descriptor :fromEntries js-object-from-entries :defineProperty js-object-define-property :setPrototypeOf js-object-set-prototype-of :getOwnPropertyNames js-object-get-own-property-names :getOwnPropertyDescriptors js-object-get-own-property-descriptors :create js-object-create :isExtensible js-object-is-extensible :is js-object-is :keys js-object-keys :getPrototypeOf js-object-get-prototype-of :isSealed js-object-is-sealed :seal js-object-seal}) (define js-delete-prop