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

False-positive unresolved-var when using potemkin #1370

Closed
ericdallo opened this issue Sep 3, 2021 · 1 comment · Fixed by #1371
Closed

False-positive unresolved-var when using potemkin #1370

ericdallo opened this issue Sep 3, 2021 · 1 comment · Fixed by #1371
Projects

Comments

@ericdallo
Copy link
Member

version

2021.08.07-20210822.045523-16

platform

JVM

editor

Happens with CLI and clojure-lsp

problem

clj-kondo reports unresolved-var for api usages where api is a namespace that uses import-var from potemkin.

repro

https://github.com/ericdallo/clojure-sample/blob/potemkin/src/clojure_sample/client.clj

First, lint the whole classpath from the project root with:

$ clj -Sdeps '{:deps {clj-kondo/clj-kondo {:mvn/version "2021.08.07-20210822.045523-16"}}}' -M -m clj-kondo.main --copy-configs --dependencies --lint $(clojure -Spath

then lint the api usage:

$ clj -Sdeps '{:deps {clj-kondo/clj-kondo {:mvn/version "2021.08.07-20210822.045523-16"}}}' -M -m clj-kondo.main --lint src/clojure_sample/client.clj
src/clojure_sample/client.clj:4:2: warning: Unresolved var: api/some-func                                                                                                                     
linting took 63ms, errors: 0, warnings: 1

config

No config.

expected behavior

Expect to not return Unresolved var: api/some-func

@borkdude borkdude added this to Needs triage in clj-kondo via automation Sep 3, 2021
@borkdude borkdude moved this from Needs triage to High priority (next release) in clj-kondo Sep 3, 2021
@borkdude
Copy link
Member

borkdude commented Sep 3, 2021

The relevant code is in clj-kondo.impl.analyzer.potemkin
think it currently only supports potemkin syntax with some vector or so and not a single symbol
So this works:

(ns clojure-sample.api
  (:require
   [clojure-sample.impl.foo]
   [potemkin :refer [import-vars]]))

(import-vars
 [clojure-sample.impl.foo some-func])

clj-kondo automation moved this from High priority (next release) to Done Sep 3, 2021
borkdude added a commit that referenced this issue Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
clj-kondo
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants