kibit icon indicating copy to clipboard operation
kibit copied to clipboard

Kibit confuses (:foo bar) and [:foo bar]

Open duck1123 opened this issue 12 years ago • 3 comments

Given the code:

(fn [bar] [:foo bar])

Kibit will suggest replacing with

:foo

which is not equivalent.

It seems that kibit can't tell the two forms apart and is giving the suggestion for:

(fn [bar] (:foo bar))

duck1123 avatar Sep 05 '12 19:09 duck1123

I came here to report the same issue. So +1.

magnars avatar Jan 25 '13 10:01 magnars

The same issue is present for all anonymous function forms resembling (fn [] [foo]), where foo is a symbol or keyword. See also issue #92. Relevant rule code is here.

Haven't had time to fully understand the semantics of the core.logic code in the relevant rule, but it seems like this could potentially have something to do with how core.logic handles unification of sequential things; the suspicious bit seems to involve clojure.core.logic/llist.

mkremins avatar Jun 05 '14 15:06 mkremins

Ran into this issue as well! A workaround is to use vector.

;; Switch from this
(fn [bar] [:foo bar])

;; To this
(fn [bar] (vector :foo bar))

;; Or this :) 
#(vector :foo %)

dehli avatar Nov 16 '18 20:11 dehli