Is function returning a function is not here yet? (I guess I found a bug maybe)
(defn my-fun []
(fn [] "foo"))
evaluates to
var my_fun = function () {
function () {
return "foo";
}
};(defn ^:async my-fun [url]
(js/await (js/fetch url)))
evaluates to:
var my_fun = async function (url) {
(await return fetch(url);)
};
but should be something like
var my_fun = async function (url) {
return await fetch(url)
};wrapping in let block is a workaround atm
sure
done: https://github.com/borkdude/cherry/issues/44 Awesome project, by the way. Love it ❤️
Thanks
Fixed in 0.0.0.alpha.43
cool, thanks. Sorry for bothering again, but is this a bug? following code:
(def arr #js [1 2 3])
compiles to
var arr = vector(1, 2, 3);This is a bug. Not bothering at all, thanks for finding the intial bugs - we need more people like you test-driving this
ok I’ll create an issue
Not sure if is it in the plans to add this behavior, but keywords are not treated as ifn in map lookups:
(def foo (:name {:name "Joe"}))
compiles to:
var foo = keyword("name")(arrayMap(keyword("name"), "Joe"));yes, should also be fixed
v45
eh
no gotta release still
v46 released
neat
By the way, how to prevent cljs watch task to fail? for example if I save a file with unbalanced parens, it prints an error:
Node.js v18.2.0
#error {
:cause "Error while executing task: watch-cljs"
:data {:proc {:proc #object[java.lang.ProcessImpl 0x5e94a421 "Process[pid=72043, exitValue=1]"], :exit 1, :in #object[java.lang.ProcessBuilder$NullOutputStream 0xa1c136c "java.lang.ProcessBuilder$NullOutputStream@a1c136c"], :out #object[java.lang.ProcessBuilder$NullInputStream 0x4adce46e "java.lang.ProcessBuilder$NullInputStream@4adce46e"], :err #object[java.lang.ProcessBuilder$NullInputStream 0x4adce46e "java.lang.ProcessBuilder$NullInputStream@4adce46e"], :prev nil, :cmd ["node" "node_modules/.bin/cherry" "index.cljs"]}, :task #'babashka.tasks/*task*, :babashka/exit 1}
:via
[{:type clojure.lang.ExceptionInfo
:message "Error while executing task: watch-cljs"
:data {:proc {:proc #object[java.lang.ProcessImpl 0x5e94a421 "Process[pid=72043, exitValue=1]"], :exit 1, :in #object[java.lang.ProcessBuilder$NullOutputStream 0xa1c136c "java.lang.ProcessBuilder$NullOutputStream@a1c136c"], :out #object[java.lang.ProcessBuilder$NullInputStream 0x4adce46e "java.lang.ProcessBuilder$NullInputStream@4adce46e"], :err #object[java.lang.ProcessBuilder$NullInputStream 0x4adce46e "java.lang.ProcessBuilder$NullInputStream@4adce46e"], :prev nil, :cmd ["node" "node_modules/.bin/cherry" "index.cljs"]}, :task #'babashka.tasks/*task*, :babashka/exit 1}
:at [babashka.impl.tasks$handle_non_zero invokeStatic "tasks.clj" 50]}]
:trace
[[babashka.impl.tasks$handle_non_zero invokeStatic "tasks.clj" 50]
[babashka.impl.tasks$shell invokeStatic "tasks.clj" 87]
[babashka.impl.tasks$shell doInvoke "tasks.clj" 59]
[clojure.lang.RestFn invoke "RestFn.java" 423]
[sci.lang.Var invoke "lang.cljc" 169]
[sci.impl.analyzer$return_call$reify__5178 eval "analyzer.cljc" 1192]
[sci.impl.analyzer$return_if$reify__4891 eval "analyzer.cljc" 660]
[sci.impl.evaluator$eval_let invokeStatic "evaluator.cljc" 71]
[sci.impl.analyzer$analyze_let_STAR_$reify__4844 eval "analyzer.cljc" 505]
[sci.impl.fns$fun$arity_1__3491 invoke "fns.cljc" 106]
[sci.impl.analyzer$return_binding_call$reify__5053 eval "analyzer.cljc" 1110]
[sci.impl.fns$fun$arity_1__3491 invoke "fns.cljc" 106]
[babashka.pods.impl$processor invokeStatic "impl.clj" 231]
[babashka.pods.sci$load_pod$fn__27096 invoke "sci.clj" 121]
[sci.impl.vars$binding_conveyor_fn$fn__395 invoke "vars.cljc" 129]
[clojure.core$binding_conveyor_fn$fn__5823 invoke "core.clj" 2047]
[clojure.lang.AFn call "AFn.java" 18]
[java.util.concurrent.FutureTask run "FutureTask.java" 264]
[java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1128]
[java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 628]
[java.lang.Thread run "Thread.java" 829]
[com.oracle.svm.core.thread.PlatformThreads threadStartRoutine "PlatformThreads.java" 704]
[com.oracle.svm.core.posix.thread.PosixPlatformThreads pthreadStartRoutine "PosixPlatformThreads.java" 202]]}
:repl/quit
and then does not recover, only restart fixes itI use watch bb task from react example
the react example doesn't have a bb.edn - can you be more specific, e.g. link to the specific file you're talking about?
Ah, right, by bad. I’m using vite example actually. https://github.com/borkdude/cherry/tree/main/examples/vite
should be fixed now
wow, cool
@thheller did some experiments with ES module, but unfortunately, binding in cljs.core generates a direct re-assignment of vars the were imported which isn't valid JS...
https://github.com/thheller/shadow-cljs/commit/e8e0cf9973bafcd472ffa1066bbd8ae8c83e5cab
A browser version of cherry: Very basic UI, wrote the index.html in a few minutes, cherry is loaded from npm via import-maps. https://borkdude.github.io/cherry/index.html