jank icon indicating copy to clipboard operation
jank copied to clipboard

Automatic arithmetic promotion

Open shantanu-sardesai opened this issue 2 months ago • 5 comments

Initial work at arithmetic promotion. The PR still requires tests but I'm creating this so that I can get some early feedback, especially on the overflow detection logic.

Requires a repoint.


Resolves https://github.com/jank-lang/jank/issues/359, https://github.com/jank-lang/jank/issues/604.

shantanu-sardesai avatar Nov 14 '25 12:11 shantanu-sardesai

I'll also aim to add missing Clojure test suite test cases for some of the arithmetic promotion operators.

shantanu-sardesai avatar Nov 14 '25 15:11 shantanu-sardesai

Interestingly enough it looks like Clojure doesn't seem to support automatic arithmetic promotion from a java.lang.Double to java.math.BigDecimal, although I've yet to receive confirmation on whether that is really the case or not. Anyone with more information or interested in the topic can follow or chime in on the discussion here.

shantanu-sardesai avatar Nov 14 '25 15:11 shantanu-sardesai

Interestingly enough it looks like Clojure doesn't seem to support automatic arithmetic promotion from a java.lang.Double to java.math.BigDecimal, although I've yet to receive confirmation on whether that is really the case or not. Anyone with more information or interested in the topic can follow or chime in on the discussion here.

Seems like Clojure intentionally chooses to not promote to BigDecimal since the promotion is to account for scale and Decimal is large enough.

shantanu-sardesai avatar Nov 25 '25 18:11 shantanu-sardesai

CI fails due to: https://github.com/jank-lang/clojure-test-suite/pull/828#discussion_r2559800068.

shantanu-sardesai avatar Dec 01 '25 14:12 shantanu-sardesai

I've commented the Clojure test suite test cases for these operators, the CI passes now.

shantanu-sardesai avatar Dec 01 '25 15:12 shantanu-sardesai