js-on-sx: relational ops ToPrimitive operands + NaN-safe le/ge
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 42s

This commit is contained in:
2026-05-09 09:13:06 +00:00
parent e4c92a19d4
commit 86f7a351fb
2 changed files with 31 additions and 6 deletions

View File

@@ -1876,6 +1876,8 @@
(fn
(v)
(cond
((or (= (type-of v) "lambda") (= (type-of v) "function") (= (type-of v) "component"))
(let ((s (js-to-string v))) s))
((not (= (type-of v) "dict")) v)
((contains? (keys v) "__js_string_value__")
(get v "__js_string_value__"))
@@ -2076,16 +2078,37 @@
js-lt
(fn
(a b)
(cond
((and (= (type-of a) "string") (= (type-of b) "string"))
(js-str-lt a b))
(else (< (js-to-number a) (js-to-number b))))))
(let
((ap (js-add-unwrap a)) (bp (js-add-unwrap b)))
(cond
((and (= (type-of ap) "string") (= (type-of bp) "string"))
(js-str-lt ap bp))
(else
(let
((an (js-to-number ap)) (bn (js-to-number bp)))
(cond
((or (js-number-is-nan an) (js-number-is-nan bn)) false)
(else (< an bn)))))))))
(define js-gt (fn (a b) (js-lt b a)))
(define js-le (fn (a b) (not (js-lt b a))))
(define
js-le
(fn
(a b)
(let
((ap (js-add-unwrap a)) (bp (js-add-unwrap b)))
(cond
((and (= (type-of ap) "string") (= (type-of bp) "string"))
(or (js-str-lt ap bp) (= ap bp)))
(else
(let
((an (js-to-number ap)) (bn (js-to-number bp)))
(cond
((or (js-number-is-nan an) (js-number-is-nan bn)) false)
(else (<= an bn)))))))))
(define js-ge (fn (a b) (not (js-lt a b))))
(define js-ge (fn (a b) (js-le b a)))
(define
js-str-lt