js-on-sx: String(arr) honours Array.prototype.toString overrides
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 48s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 48s
Was always emitting comma-joined via js-list-join, so user mutations of Array.prototype.toString had no effect on String(arr) / "" + arr. Now look up the override via js-dict-get-walk and call it on the list as this; fall back to (js-list-join v ",") when the override doesn't return a string. String fail count: 11 → 9. conformance.sh: 148/148.
This commit is contained in:
@@ -1402,7 +1402,15 @@
|
||||
(js-to-string result)))
|
||||
"[object Object]"))))
|
||||
(cond
|
||||
((= (type-of v) "list") (js-list-join v ","))
|
||||
((= (type-of v) "list")
|
||||
(let
|
||||
((tostr-fn (js-dict-get-walk (get Array "prototype") "toString")))
|
||||
(if
|
||||
(= (type-of tostr-fn) "lambda")
|
||||
(let
|
||||
((result (js-call-with-this v tostr-fn ())))
|
||||
(if (= (type-of result) "string") result (js-list-join v ",")))
|
||||
(js-list-join v ","))))
|
||||
((js-function? v)
|
||||
(let
|
||||
((tostr-fn (js-dict-get-walk (get js-function-global "prototype") "toString")))
|
||||
|
||||
Reference in New Issue
Block a user