<< Back to previous view

[CLJS-1223] cljs.repl/doc for unqualified .. macro Created: 24/Apr/15  Updated: 24/Apr/15

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: 0.0-3126
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Note: Also affects 0.0-3211 (not yet available in JIRA pulldown)
Quick Start cljs.jar
OS X



 Description   

In the REPL, (doc ..) fails, while it succeeds for similar macros like (doc ->), and it also succeeds for ns-qualified: (doc cljs.core/..).

$ java -jar cljs.jar -m cljs.repl.node
ClojureScript Node.js REPL server listening on 54359
To quit, type: :cljs/quit
cljs.user=> *clojurescript-version*
"0.0-3211"
cljs.user=> (doc ..)
-------------------------
/.
  nil

nil
cljs.user=> (doc cljs.core/..)
-------------------------
cljs.core/..
([x form] [x form & more])
Macro
  form => fieldName-symbol or (instanceMethodName-symbol args*)

  Expands into a member access (.) of the first member on the first
  argument, followed by the next member on the result, etc. For
  instance:

  (.. System (getProperties) (get "os.name"))

  expands to:

  (. (. System (getProperties)) (get "os.name"))

  but is easier to write, read, and understand.

nil





[CLJS-1222] Sequence of a stateful transducer is producing the wrong answer Created: 24/Apr/15  Updated: 24/Apr/15

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: 0.0-3211
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Lucas Cavalcanti Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: bug, cljs, collections
Environment:

OSX 10.10.3, java 1.8.0-ea-b124



 Description   

I'm producing more than one element on the 1-arity of the transducer, and sequence is only considering the last one.

core.async is working as expected, but sequence is not. I implemented the same transducer on clojure and it works fine for sequence.

Here is the transducer and the tests that pass for core.async and fail for sequence:

======

(defn sliding-window [n]
(fn [rf]
(let [a #js []]
(fn
([] (rf))
([result]
(loop [] ;; Here I'm emitting more than one element
(when (not-empty a)
(rf result (vec (js->clj a)))
(.shift a)
(recur))))
([result input]
(.push a input)
(if (== n (.-length a))
(let [v (vec (js->clj a))]
(.shift a)
(rf result v))
result))))))

(deftest sliding-window-in-a-channel
(testing "sliding"
(let [channel (async/chan 1 (sliding-window 3))]
(async done
(go (async/>! channel 1)
(async/>! channel 2)
(async/>! channel 3)
(async/>! channel 4)
(async/>! channel 5)
(async/close! channel))

(go
(is (= (async/<! channel) [1 2 3]))
(is (= (async/<! channel) [2 3 4]))
(is (= (async/<! channel) [3 4 5]))
(is (= (async/<! channel) [4 5]))
(is (= (async/<! channel) [5]))
(is (= (async/<! channel) nil))
(done))))))

(deftest sliding-window-with-few-elements
(testing "with less elements"
(let [channel (async/chan 1 (sliding-window 3))]
(async done
(go (async/>! channel 1)
(async/>! channel 2)
(async/close! channel))

(go
(is (= (async/<! channel) [1 2]))
(is (= (async/<! channel) [2]))
(is (= (async/<! channel) nil))
(done))))))

;;This test fails! =(
(deftest sliding-window-in-a-sequence
(is (= [[5 4 3]
[4 3 2]
[3 2 1]
[2 1]
[1]]
(sequence (sliding-window 3) [5 4 3 2 1])))

(is (= [[2 1]
[1]]
(sequence (sliding-window 3) [2 1]))))



 Comments   
Comment by Lucas Cavalcanti [ 24/Apr/15 11:18 AM ]

I could make it work by recurring on the result.

([result]
  (loop [res result]
    (if (not-empty a)
      (let [v (vec (js->clj a))]
        (.shift a)
        (recur (rf res v)))
      res)))

even so it's weird that the previous version behaves differently on core.async and sequences in cljs and clj





[CLJS-1221] deftype/defrecord getBasis static method Created: 24/Apr/15  Updated: 24/Apr/15

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: 0.0-3211
Fix Version/s: Next

Type: Defect Priority: Major
Reporter: David Nolen Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None





[CLJS-1220] Invalid regexp in src/clj/cljs/util.clj:130 Created: 23/Apr/15  Updated: 23/Apr/15  Resolved: 23/Apr/15

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: Next
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Marek Lipert Assignee: Unassigned
Resolution: Not Reproducible Votes: 0
Labels: None
Environment:

any



 Description   

There is an error in regex introduced in this commit:

https://github.com/clojure/clojurescript/commit/4228ee3a5dad6b04b1f852cb87138ac5c6d595be



 Comments   
Comment by David Nolen [ 23/Apr/15 7:52 PM ]

Tickets must present enough information to reproduce. Please include all information (environment etc.) necessary to replicate. Feel free to reopen when you can supply this.





[CLJS-1219] Eval doesn't work as expected Created: 23/Apr/15  Updated: 23/Apr/15  Resolved: 23/Apr/15

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: 0.0-3126
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Alex Gunnarson Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

Mac OS X Yosemite (10.10.1), lein-figwheel "0.2.7-SNAPSHOT"



 Description   

I've been doing some tests with macros and |eval| in ClojureScript and it doesn't work as expected. Here is the test file I'm using, which figwheel is reloading (src/cljc/quantum/test_fns.cljc):

=======================
(ns quantum.test-fns)

#?(:clj (defmacro eval-test0 [arg] `(eval '~arg)))
#?(:clj (defmacro eval-test1 [arg] (eval `~arg)))

#?(:clj
(defmacro mfn
"|mfn| is short for 'macro-fn'.
Originally named |functionize| by mikera."
{:attribution "mikera, http://stackoverflow.com/questions/9273333/in-clojure-how-to-apply-a-macro-to-a-list/9273560#9273560"}
[macro]
`(fn [& args#]
(eval (cons '~macro args#)))))

#?(:clj
(defmacro mfn-test
[macro]
(fn [& args]
(eval `(cons '~macro args)))))
=======================

I've been trying to get the macro |mfn| working, to be able to create macro aliases in ClojureScript like so:

=======================
(def cljs-for (mfn for))
(defalias lazy-for cljs-for)
=======================

By the way, the equivalent code in Clojure is a lot shorter and simpler, but it doesn't work in ClojureScript:

=======================
(defalias lazy-for for)
=======================

At the moment, |mfn| works in Clojure but not in ClojureScript. The error is as follows:

=======================
quantum.test => (quantum.test-fns/mfn 0)
WARNING: Use of undeclared Var cljs.core/eval at line 1 <cljs repl>
#<TypeError: Cannot read property 'call' of undefined>
=======================

So then I tried testing |eval| all by itself. I realize that runtime |eval| is not supported in ClojureScript, but from what I've read, it is supported within Clojure macros referenced by ClojureScript code. So I tried the following:

=======================
quantum.test => (eval-test0/mfn 0)
=======================

This gave the same error as calling |mfn|. So I tried the following next, which worked for CLJS-278 (http://dev.clojure.org/jira/browse/CLJS-278):

=======================
quantum.test => (eval-test1/mfn 0)
0
=======================

This, as you can see, works. So the problem seems to be nesting |eval| within a syntax-quote. With this in mind, I intended to patch |mfn| with |mfn-test|. So I called it like so, with the following result:

=======================
quantum.test => (quantum.test-fns/mfn-test 0)
java.lang.IllegalArgumentException: No method in multimethod 'emit-constant' for dispatch value: class quantum.test_fns$mfn_test$fn__94072
at clojure.lang.MultiFn.getFn(MultiFn.java:156)
at clojure.lang.MultiFn.invoke(MultiFn.java:229)
at cljs.compiler$eval2597$fn__2599.invoke(compiler.clj:355)
at clojure.lang.MultiFn.invoke(MultiFn.java:229)
at cljs.compiler$emit.invoke(compiler.clj:137)
at cljs.compiler$emit_str.invoke(compiler.clj:165)
at cljs.repl$evaluate_form.invoke(repl.clj:423)
at cljs.repl$eval_cljs.invoke(repl.clj:542)
at cljs.repl$repl_STAR_$read_eval_print__4217.invoke(repl.clj:808)
at cljs.repl$repl_STAR_$fn_4223$fn_4230.invoke(repl.clj:845)
at cljs.repl$repl_STAR_$fn__4223.invoke(repl.clj:844)
at cljs.compiler$with_core_cljs.invoke(compiler.clj:964)
at cljs.repl$repl_STAR_.invoke(repl.clj:810)
at figwheel_sidecar.repl$repl.invoke(repl.clj:172)
at figwheel_sidecar.repl$start_repl.invoke(repl.clj:389)
at figwheel_sidecar.repl$cljs_repl.invoke(repl.clj:405)
at figwheel_sidecar.repl$repl_switching_loop.invoke(repl.clj:416)
at figwheel_sidecar.repl$repl_switching_loop.invoke(repl.clj:412)
at figwheel_sidecar.repl$run_autobuilder.invoke(repl.clj:455)
at user$eval17648.invoke(form-init3534144446427289738.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6792)
at clojure.lang.Compiler.eval(Compiler.java:6782)
at clojure.lang.Compiler.load(Compiler.java:7237)
at clojure.lang.Compiler.loadFile(Compiler.java:7175)
at clojure.main$load_script.invoke(main.clj:275)
at clojure.main$init_opt.invoke(main.clj:280)
at clojure.main$initialize.invoke(main.clj:308)
at clojure.main$null_opt.invoke(main.clj:343)
at clojure.main$main.doInvoke(main.clj:421)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
=======================

This seems to be a problem with ClojureScript, but I may be wrong. Please do let me know.



 Comments   
Comment by David Nolen [ 23/Apr/15 7:50 PM ]

We do not look at tickets that involve tooling beyond involving anything other than ClojureScript. This ticket also suffers from not being a minimal case (conditional reading + something about eval). Feel free to open a new ticket that represents a minimal issue (only one dimension) using only ClojureScript thanks.





[CLJS-1218] Syntax quoting an alias created with :require-macros throws ClassCastException Created: 22/Apr/15  Updated: 23/Apr/15

Status: Reopened
Project: ClojureScript
Component/s: None
Affects Version/s: 0.0-3196
Fix Version/s: 0.0-3211

Type: Defect Priority: Minor
Reporter: Ryan Berdeen Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

With ClojureScript 0.0-3196 or the current cljs.jar, ClojureScript fails to read this file:

a.cljs
(ns a
  (:require-macros [clojure.string :as alias]))
 
; this is fine
`xxx/name
 
; this throws clojure.lang.Symbol cannot be cast to clojure.lang.Namespace
`alias/name
java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.Namespace
        at clojure.tools.reader$resolve_symbol.invoke(reader.clj:633)
        at clojure.tools.reader$syntax_quote_STAR_.invoke(reader.clj:677)
        at clojure.tools.reader$read_syntax_quote.invoke(reader.clj:724)
        at clojure.tools.reader$read_STAR_.invoke(reader.clj:873)


 Comments   
Comment by David Nolen [ 22/Apr/15 11:59 PM ]

Please open an issue in tools.reader first. If it's determined that that is the not source, then you can reopen this one.

Comment by Nicola Mometto [ 23/Apr/15 6:13 AM ]

Not a tools.reader bug – cljs is binding alias-map to a map of sym->sym, the documentation for alias-map talks about mapping ns alias -> ns.

However I realize that providing sym->ns mapping could be problematic for cljs so I've just cut a tools.reader 0.9.2 release allowing for sym->sym mapping (see https://github.com/clojure/tools.reader/commit/6ca3b8899fe3884706fbeb176c008dc43643dc4b)





[CLJS-1217] cljs.test/run-tests with default env has no way to access summary Created: 21/Apr/15  Updated: 23/Apr/15

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: 0.0-3196
Fix Version/s: Next

Type: Enhancement Priority: Major
Reporter: Jenan Wise Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

clojure.test/run-tests returns a summary map that can be used to programmatically determine if a test has any errors or failures. As of the inclusion of async tests, cljs.test/run-tests returns nil. This makes it a bit verbose and redundant to write test runners that wish to use the default reporting but need to signal programmatically when there are errors or failures (such as when integrating with continuous build systems). As far as I can tell, the easiest approach under the current implementation looks like this:

;; All we care about is the error+fail count
;; and want cljs.test to print everything else as
;; normal.

(def error-count (atom 0))

(defmethod report [::test :pass] [m]
  ((get-method report [:cljs.test/default :pass]) m))

(defmethod report [::test :begin-test-ns] [m]
  ((get-method report [:cljs.test/default :begin-test-ns]) m))

(defmethod report [::test :error] [m]
  (swap! error-count inc)
  ((get-method report [:cljs.test/default :error]) m))

(defmethod report [::test :fail] [m]
  (swap! error-count inc)
  ((get-method report [:cljs.test/default :fail]) m))

(defmethod report [::test :summary] [m]
  ((get-method report [:cljs.test/default :summary]) m))

(defn runner
  []
  (run-tests (empty-env ::test) '...))

(from here)

This is true even when only sync tests are being used.

The docs mention that there is no support for coordination in cljs.test, which makes sense, but it seems like there should be a way to access the summary value without writing all of the report methods. Also, under the current implementation cljs.test/successful? appears to be unusable.






[CLJS-1216] varargs not passed properly Created: 21/Apr/15  Updated: 23/Apr/15  Resolved: 23/Apr/15

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: 0.0-3196
Fix Version/s: 0.0-3211

Type: Defect Priority: Critical
Reporter: Karsten Schmidt Assignee: David Nolen
Resolution: Completed Votes: 2
Labels: compiler


 Description   

The following is broken as of 3196 (3165 is still working correctly)

(defn foo
  ([a] (foo a 10))
  ([a b & [c]] [a b c]))

(foo 1)
;; => [1 (10) nil] => should be [1 10 nil]

(foo 1 2)
;; => [1 (2) nil] => should be [1 2 nil]

(foo 1 2 3)
;; => [1 (2 3) nil] => should be [1 2 3]


 Comments   
Comment by Stephen Nelson [ 21/Apr/15 7:18 PM ]

This only occurs with defns that have multiple bodies, it does not occur with fns or with defns with a single body, or when the defn is called via apply rather than directly. Seems like it might be an off-by-one error in the calculation of required arguments in the defn dispatcher function. Test case:

test/dispatch_test.cljs
(ns test.destructuring-test
  (:require [cljs.test :refer-macros [deftest is]]))

(defn destructure
  ([kvs]
   kvs)
  ([k v & args]
   [k v args]))

(deftest test-destructuring
  (is (= [1 2 [3 4]]                                        ;; fails
         (destructure 1 2 3 4)))
  (is (= [1 2 [3 4]]                                        ;; passes
         (apply destructure [1 2 3 4])))
  )

In the compiled javascript the default case of the dispatcher only pulls one argument off before calling the variadic body, whereas the applyTo body pulls two off. Seems like the dispatcher is at fault.

test/dispatch_test.js
...
test.destructuring_test.destructure = (function test$destructuring_test$destructure() {
    var G__48557 = arguments.length;
    switch (G__48557) {
        case 1:
            return test.destructuring_test.destructure.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));

            break;
        default:
            var argseq__17948__auto__ = (new cljs.core.IndexedSeq(Array.prototype.slice.call(arguments, 1), (0)));
            return test.destructuring_test.destructure.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]), argseq__17948__auto__);

    }
});

test.destructuring_test.destructure.cljs$core$IFn$_invoke$arity$1 = (function (kvs) {
    return kvs;
});

test.destructuring_test.destructure.cljs$core$IFn$_invoke$arity$variadic = (function (k, v, args) {
    return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [k, v, args], null);
});

test.destructuring_test.destructure.cljs$lang$applyTo = (function (seq48553) {
    var G__48554 = cljs.core.first.call(null, seq48553);
    var seq48553__$1 = cljs.core.next.call(null, seq48553);
    var G__48555 = cljs.core.first.call(null, seq48553__$1);
    var seq48553__$2 = cljs.core.next.call(null, seq48553__$1);
    return test.destructuring_test.destructure.cljs$core$IFn$_invoke$arity$variadic(G__48554, G__48555, seq48553__$2);
});
...
Comment by Karsten Schmidt [ 22/Apr/15 5:20 AM ]

You're right, Stephen! I've narrowed down the first occurrence, it's starting at r3178 - most likely with the changes done to cljs.core in this commit: https://github.com/clojure/clojurescript/commit/576fb6e054dd50ec458a3c9e4172a5a0002c7aea

will dig more & attempt a patch later today...

Comment by David Nolen [ 23/Apr/15 12:34 AM ]

I have a fix for this, just a simple error around computing the max fixed arity.

Comment by David Nolen [ 23/Apr/15 12:39 AM ]

fixed https://github.com/clojure/clojurescript/commit/c2296b11cc89a81baef1cd6a11567150d48605d9

Comment by David Nolen [ 23/Apr/15 12:51 AM ]

Cut 0.0-3211 with this fix.





[CLJS-1215] Guard against older Clojure dep Created: 21/Apr/15  Updated: 23/Apr/15  Resolved: 23/Apr/15

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: 0.0-3126
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Mike Fikes Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

OS X



 Description   

Not sure if this is even the responsibility of, or possible to address from, the ClojureScript compiler, but here is the ask: If someone uses a project.clj specifying Clojure 1.6.0, emit a warn or balk. (I'm only thinking this is remotely possible from within the ClojureScript compiler if it can check the version of Clojure being used prior to making calls into Clojure.)

Rationale: Discovered a case where important compiler/analyzer warnings were not being emitted until project.clj was revised to specify Clojure 1.7.0-beta1.

Here is a minimal setup exhibiting the problem, (including both Quick Start and cljsbuild bits so it is easy to see the effects of the setup):

src/foo/bar.cljs:

(ns foo.bar
  (:require-macros [foo.macros :refer [call]]))

(call)

src/foo/macros.clj:

(ns foo.macros)

(defmacro call []
  `(foo.baz/quux))

src/foo/baz.cljs:

(ns foo.baz)

(defn quux [])

build.clj (meant to be used with cljs.jar):

(require 'cljs.closure)

(cljs.closure/build "src"
  {:output-to "main.js"})

project.clj:

(defproject ex "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/clojurescript "0.0-3196"]]
  :plugins [[lein-cljsbuild "1.0.5"]]
  :source-paths ["src"]
  :cljsbuild {
    :builds [{:id "dev"
              :source-paths ["src"]
              :compiler {
                :output-to "main.js"}}]})

In the above project, the code is missing an important :require and the emitted JavaScript will be bad for :none. The good thing is the compiler warns about it:

$ java -cp cljs.jar:src clojure.main build.clj
WARNING: Use of undeclared Var foo.baz/quux at line 4 src/foo/bar.cljs

But, if cljsbuild is used, no warning is issued:

$ rm main.js
$ lein cljsbuild once dev
Compiling ClojureScript.
Compiling "main.js" from ["src"]...
Successfully compiled "main.js" in 4.567 seconds.

If the project.clj is revised to specify 1.7.0-beta1, then:

$ rm main.js 
$ lein cljsbuild once dev
Compiling ClojureScript.
Compiling "main.js" from ["src"]...
WARNING: Use of undeclared Var foo.baz/quux at line 4 src/foo/bar.cljs
Successfully compiled "main.js" in 4.258 seconds.


 Comments   
Comment by Mike Fikes [ 21/Apr/15 1:37 PM ]

An additional note:

If you downgrade the ClojureScript dep in project.clj to 0.0-3126 and use it specifying Clojure 1.6.0, then the desired warning is emitted:

$ lein cljsbuild once dev
Compiling ClojureScript.
Compiling "main.js" from ["src"]...
WARNING: Use of undeclared Var foo.baz/quux at line 4 src/foo/bar.cljs
Successfully compiled "main.js" in 3.969 seconds.

(In other words, the issue at the core of this ticket only happens if and only if you upgrade to the most recent ClojureScript and fail to also upgrade to the required Clojure dep.)

Comment by David Nolen [ 23/Apr/15 12:04 AM ]

Doing this isn't in scope. All the current tools have good support for detecting such issues and the new uberjar for people exploring ClojureScript for the first time doesn't have this problem.





[CLJS-1214] :arglists meta has needless quoting Created: 21/Apr/15  Updated: 23/Apr/15

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: 0.0-3196
Fix Version/s: Next

Type: Defect Priority: Major
Reporter: David Nolen Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None





[CLJS-1213] cljs.analyzer incorrectly marks all defs as tests when eliding test metadata Created: 20/Apr/15  Updated: 23/Apr/15

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: 0.0-3196
Fix Version/s: Next

Type: Defect Priority: Minor
Reporter: Stephen Nelson Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/analyzer.clj#L861

Cond threading will unconditionally assoc :test true when eliding test metadata for a namespace def.

This prevents accurate detection of test vars in cljs macros.






Generated at Sun Apr 26 03:27:29 CDT 2015 using JIRA 4.4#649-r158309.