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

Cannot use :rename in (:refer-clojure ...) #558

Closed
sh54 opened this issue Apr 9, 2021 · 1 comment
Closed

Cannot use :rename in (:refer-clojure ...) #558

sh54 opened this issue Apr 9, 2021 · 1 comment

Comments

@sh54
Copy link

sh54 commented Apr 9, 2021

I was trying to use babashka to load in something that had a :refer-clojure bit in it.

It appears that sci does not support that option since the case form in the following throws:

https://github.com/borkdude/sci/blob/9fe09b627bab2b6a41a891744f10836b2ac00454/src/sci/impl/load.cljc#L194-L215

How to (roughly) reproduce:

target.clj

(ns target
  (:refer-clojure :exclude [str]
                  :rename  {bit-shift-left <<}))

program.clj

#!/usr/bin/env bb

(require '[babashka.classpath :refer [add-classpath]])

(add-classpath "some-class-path")

(try
  (require '[target])
  (catch Throwable e
    (println :error e)))

Error

#error {
 :cause No matching clause: :rename
 :via
 [{:type java.lang.IllegalArgumentException
   :message No matching clause: :rename
   :at [clojure.core$case_fallthrough_err_impl invokeStatic core.clj 6698]}]
 :trace
 [[clojure.core$case_fallthrough_err_impl invokeStatic core.clj 6698]
  [sci.impl.load$eval_refer_clojure invokeStatic load.cljc 207]
  [sci.impl.load$eval_refer invokeStatic load.cljc 260]
  [sci.impl.load$eval_refer doInvoke load.cljc 255]
  [clojure.lang.RestFn applyTo RestFn.java 142]
  [clojure.core$apply invokeStatic core.clj 669]
  [sci.impl.evaluator$eval_special_call invokeStatic evaluator.cljc 331]
  [sci.impl.evaluator$eval_call invokeStatic evaluator.cljc 361]
  [sci.impl.evaluator$eval invokeStatic evaluator.cljc 403]
  [sci.impl.analyzer$return_do$fn__17577 invoke analyzer.cljc 117]
  [sci.impl.evaluator$eval invokeStatic evaluator.cljc 390]
  [sci.impl.interpreter$eval_form invokeStatic interpreter.cljc 77]
  [sci.impl.interpreter$eval_string_STAR_ invokeStatic interpreter.cljc 113]
  [sci.impl.interpreter$eval_string_STAR_ invoke interpreter.cljc 107]
  [sci.impl.load$handle_require_libspec$fn__17055 invoke load.cljc 105]
  [sci.impl.load$handle_require_libspec invokeStatic load.cljc 102]
  [sci.impl.load$load_lib invokeStatic load.cljc 132]
  [sci.impl.load$load_lib doInvoke load.cljc 126]
  [clojure.lang.RestFn applyTo RestFn.java 146]
  [clojure.core$apply invokeStatic core.clj 671]
  [sci.impl.load$load_libs invokeStatic load.cljc 173]
  [sci.impl.load$eval_require invokeStatic load.cljc 182]
  [sci.impl.load$eval_require doInvoke load.cljc 182]
  [clojure.lang.RestFn applyTo RestFn.java 139]
  [clojure.core$apply invokeStatic core.clj 669]
  [sci.impl.namespaces$require invokeStatic namespaces.cljc 509]
  [sci.impl.namespaces$require doInvoke namespaces.cljc 509]
  [clojure.lang.RestFn applyTo RestFn.java 139]
  [clojure.lang.AFunction$1 doInvoke AFunction.java 31]
  [clojure.lang.RestFn invoke RestFn.java 421]
  [sci.impl.analyzer$return_needs_ctx_call$fn__18355 invoke analyzer.cljc 779]
  [sci.impl.evaluator$eval invokeStatic evaluator.cljc 390]
  [sci.impl.evaluator$eval invoke evaluator.cljc 385]
  [sci.impl.evaluator$eval_try invokeStatic evaluator.cljc 133]
  [sci.impl.evaluator$eval invokeStatic evaluator.cljc 403]
  [sci.impl.interpreter$eval_form invokeStatic interpreter.cljc 77]
  [sci.impl.interpreter$eval_string_STAR_ invokeStatic interpreter.cljc 113]
  [sci.core$eval_string_STAR_ invokeStatic core.cljc 211]
  [babashka.main$exec$fn__30798$fn__30799 invoke main.clj 694]
  [babashka.main$exec$fn__30798 invoke main.clj 694]
  [babashka.main$exec invokeStatic main.clj 687]
  [babashka.main$main invokeStatic main.clj 737]
  [babashka.main$main doInvoke main.clj 737]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [clojure.core$apply invokeStatic core.clj 667]
  [babashka.main$_main invokeStatic main.clj 749]
  [babashka.main$_main doInvoke main.clj 741]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [babashka.main main nil -1]]}

I was trying to load some helper code that is used by the main project.

It would also be nice if the problematic file was reported somehow. Though I have just started playing with babashka so maybe I am missing out on something there.

@borkdude
Copy link
Collaborator

borkdude commented Apr 9, 2021

Fixed on master

@borkdude borkdude closed this as completed Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants