Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reports spurious error for RoundingMode enums in core macro with-precision #1678

Closed
skylize opened this issue May 2, 2022 · 1 comment
Closed

Comments

@skylize
Copy link

skylize commented May 2, 2022

version

2022.04.25

macro usage

Related to a macro provided by clojure.core: with-precision

problem

Clojure core includes a macro with-precision to set both precision and rounding mode for BigDecimal operations.

The macro optionally accepts an argument :rounding, which must be followed by one of CEILING, FLOOR, HALF_UP, HALF_DOWN, HALF_EVEN, UP, DOWN, and UNNECESSARY. The macro translates this to a matching enum constant from java.math.RoundingMode for use in the proceeding expression.

When used, Clj-kondo reports the enum names as "Unresolved symbol". They are not symbols. They are merely characters to be interpreted by the macro.

repro

--- clj_kondo_with_precision.clj ---

(ns clj-kondo-with-precision)

;; Example copied from clojure core `master` branch:
;;   `test/clojure/test_clojure/vars.clj`: line: 45
(with-precision 6 :rounding CEILING (+ 3.5555555M 1))

on command line

$ clj-kondo --lint clj_kondo_with_precision.clj
clj_kondo_with_precision.clj:5:29: error: Unresolved symbol: CEILING
linting took 12ms, errors: 1, warnings: 0

expected behavior

Since this is a core macro, and all legal entries are fully enumerated in the docs, the linter should not require any special configuration to prevent reporting an error for any of the specified enums within the context of with-precision.

@borkdude borkdude added this to Needs triage in clj-kondo via automation May 2, 2022
@borkdude
Copy link
Member

borkdude commented May 2, 2022

Agreed, this should be fixed.

@borkdude borkdude moved this from Needs triage to High priority (next release) in clj-kondo May 2, 2022
@borkdude borkdude moved this from High priority (next release) to In progress in clj-kondo May 26, 2022
clj-kondo automation moved this from In progress to Done May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
clj-kondo
  
Done
Development

No branches or pull requests

2 participants