Fork me on GitHub
#cljs-dev
<
2022-01-28
>
quoll02:01:18

Working on incorporating Alex’s tests, I’m noticing the new functions in Clojure 1.11. I see that CLJS-3331 (add update-vals and update-keys) addressed 2 of the functions, but I can’t see any of the other functions mentioned. Should I go ahead and add a ticket for them? Happy to implement if no one else has done it

quoll02:01:21

The functions are: parse-long, parse-double, parse-uuid, parse-boolean, NaN?, and infinite?

Alex Miller (Clojure team)02:01:30

please carefully match the semantics in the Clojure functions for valid string / invalid string / non-string

Alex Miller (Clojure team)02:01:27

The results in those partitions are parsed value / nil / exception respectively

👍 1
quoll02:01:08

I’ve put up a new patch on https://clojure.atlassian.net/browse/CLJS-3347: • removed the autogenerated version number • Incorporated Clojure tests • Renamed a function that was renamed in Clojure between alpha3 and alpha4 (`clojure.java.math/negative-exact` -> clojure.math/negate-exact)

quoll16:01:34

Added https://clojure.atlassian.net/browse/CLJS-3348 to introduce the new functions I mentioned last night

quoll17:01:27

Thank you!

dnolen17:01:30

looks like all test passing, will try to do a closer review soon

mfikes13:02:58

I still have an old AppVeyer setup running and a couple tests failed there: https://ci.appveyor.com/project/mfikes/clojurescript/builds/42411989

mfikes22:02:17

Taking a peek at some odd self-hosted test failures...

quoll22:02:26

Almost all of these seem to be based on the distinction between -0 and 0 being lost. One stood out for me on lines 76-78:

FAIL in (test-pow) ([object Object]:170:7)
expected: (= ##-Inf (m/pow 0 -3))
  actual: (not (= ##-Inf ##Inf))
That’s strange, because Math.pow(0, -3) is positive infinity (that’s the same in both Java and JavaScript). So I looked at the original code:
(is (= ##-Inf (m/pow -0.0 -3.0)))
So the code being executed appears to be different to the original source. This suggests to me that the code being sent to the self-hosted compiler has been read and converted back into a string, and that leads to the -0 values losing their sign. Is that a thing that happens Mike?

mfikes22:02:57

There are probably symbols not intended to be public, like MAX-FLOAT-VALUE (see https://gist.github.com/mfikes/eec91b7aab55c093ca9bcb2f892633aa) (I suspect dir on the Clojure and ClojureScript versions of this namespace would produce the same list of public names in the end)

quoll22:02:05

I’m wondering why I left them public. I made the other values private 😕

mfikes22:02:01

Ahh, so @quoll in JVM ClojureScript, the reader is implemented in Clojure and evidently it can read -0.0, but the self-hosted reader doesn't handle the numeric literal -0.0 in that way...

quoll22:02:17

Ah… they’re to equate to Double/MAX_VALUE and Double/MIN_VALUE

quoll22:02:35

These are important constants to have access to. I need them internally, and because anyone in Clojure land can refer to these values I made them available for ClojureScript too… but with different names

mfikes22:02:22

JVM ClojureScript:

cljs.user=> (/ -0.0)
##-Inf
Self-hosted ClojureScript (Planck):
cljs.user=> (/ -0.0)
##Inf

quoll22:02:33

Nope… I made a mistake. They’re already in JavaScript. I should reuse those values and not redefine them. I’ll fix that now

mfikes22:02:37

So, this is likely down to a difference in the reader implementations

mfikes22:02:56

Perhaps it could be deemed a bug in the ClojureScript implementation of the reader...

quoll22:02:33

Given that JavaScript reads these numbers and represents them internally correctly, then it would seem so?

mfikes01:02:39

Turns out the problem is not with the self-hosted reader, but at the other end (emission). Fix in https://clojure.atlassian.net/jira/software/c/projects/CLJS/issues/CLJS-3352

mfikes02:02:26

Cool, putting it all together with Paula's 2nd patch passes: https://github.com/clojure/clojurescript/commits/cljs-math-test-2

bananadance 1
quoll23:02:39

I’ve added what I hope is the final path to https://clojure.atlassian.net/browse/CLJS-3347 This includes the tests on self-hosted since that now passes