babashka / nbb

Scripting in Clojure on Node.js using SCI
Eclipse Public License 1.0
863 stars 52 forks source link

Investigate refer conflict with clojure.core var #16

Closed borkdude closed 8 months ago

borkdude commented 3 years ago
(require '["shelljs" :as sh :refer [cat]])

(prn (str (cat "shelljs.cljs")))

We should support :refer-clojure :exclude [cat] in this case or else give an error.

borkdude commented 3 years ago

It should probably work like this:

user=> (ns foo (:refer-clojure :exclude [cat]))
nil
foo=> (deftype cat [])
foo.cat
foo=> foo.cat
foo.cat
foo=> (ns bar (:refer-clojure :exclude [cat]) (:import [foo cat]))
nil
bar=> cat
foo.cat
bar=>
borkdude commented 3 years ago

refer-clojure now works, but I think both SCI and nbb should emit a warning here as well.

borkdude commented 3 years ago

ClojureScript:

ClojureScript 1.10.866
cljs.user=>  (ns foo.baz (:require [goog.object :refer [get]]))

nil
foo.baz=> foo.baz=>
foo.baz=>
foo.baz=> get
#object[Function]
foo.baz=> (get #js{:a 1} "a")
1
borkdude commented 8 months ago

Most recent repro:

(ns bar (:require ["fs" :refer [existsSync] :rename {xexists? exists?}])) (exists? 1)