<< Back to previous view

[CLJS-1762] Bump Closure Compiler Created: 22/Aug/16  Updated: 27/Sep/16

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

Type: Task Priority: Minor
Reporter: António Nuno Monteiro Assignee: Juho Teperi
Resolution: Unresolved Votes: 0
Labels: closure

Attachments: Text File CLJS-1762-3.patch     Text File CLJS-1762.patch    

 Description   

A new version of the Closure Compiler features an optimization that results in faster compilation, as well as some some changes to ES6-related features.



 Comments   
Comment by Juho Teperi [ 27/Aug/16 4:39 AM ]

Here is my version of the change.

Updating cljs.closure was quite straightforward, just removed all the checks and changed a few constructor calls.

I think I found all places to update the Closure version: pom.template.xml, project.clj and script/bootstrap. Bootstrap script also needed a change to account for changes closure-compiler filename.

  • ES6ModuleLoader has been replaced with ModuleLoader, it no longer
    needs to be passed to ProcessCommonJSModules etc. constructors
  • This version requires the version 20160822 and any checks needed to
    work with older versions have been removed
  • Closure-compiler jar name has been changed so lib/ and closure/
    directories should be removed before running bootstrap
Comment by Juho Teperi [ 27/Aug/16 4:55 AM ]

While tests pass with the patch, looks like module processing is broken. Tested with https://github.com/mneise/circle-color

Comment by Juho Teperi [ 15/Sep/16 5:19 AM ]

Current WIP branch at https://github.com/clojure/clojurescript/compare/master...Deraen:cljs-1762

I started writing some tests for module processing based on Mneise's circle-color example. I heavily simplified React UMD module and JSX processing for the tests, but not yet very happy with this method. Probably best to write the JS for tests from scratch.

Currently stuck on getting Closure compiler to return the processed code: https://github.com/clojure/clojurescript/compare/master...Deraen:cljs-1762#diff-84ffd22349e5ca1fe6322cb0e379b3b1R1530

Comment by Juho Teperi [ 27/Sep/16 5:15 PM ]

Proposed patch. Contains several FIXME notes, some I know how to fix, on others I would like to have some comments what would be best way to solve them.





[CLJS-1782] Self-host: allow namespaces to require their own macros Created: 19/Sep/16  Updated: 27/Sep/16

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

Type: Defect Priority: Major
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Unresolved Votes: 1
Labels: None

Attachments: Text File CLJS-1782.patch    
Patch: Code

 Description   

Currently a namespace can only require its own macros in JVM ClojureScript (called macro-loop in this post).

Because there's no reader conditional distinction between JVM and Bootstrapped ClojureScript, requiring a namespace that requires its own macros in self-host will result in the following error:

Could not require foo.core in file /Users/anmonteiro/Desktop/foo/src/foo/core.cljc
Maximum call stack size exceeded.

Below is an example that can be used to reproduce the issue:

;; foo/core.cljc
(ns foo.core
  #?(:cljs (:require-macros [foo.core])))

(defmacro a-macro [& args]
  `(println ~@args))

This ticket proposes the following solution: when loading a macros namespace in self-hosted ClojureScript, patch its `require-macros` and `use-macros` entries to remove itself, if present.



 Comments   
Comment by António Nuno Monteiro [ 19/Sep/16 9:09 PM ]

Attached patch with proposed fix.

Comment by António Nuno Monteiro [ 27/Sep/16 8:05 AM ]

Replaced the patch with a new one rebased on current master.





[CLJS-1794] incomplete alias created for namespace cljs.spec warning under advanced compilation Created: 26/Sep/16  Updated: 26/Sep/16

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

Type: Defect Priority: Major
Reporter: Michael Glaesemann Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

λ lein --version
Leiningen 2.6.1 on Java 1.8.0_45 Java HotSpot(TM) 64-Bit Server VM



 Description   

Under advanced compilation, use of cljs.spec can cause analyzer warnings.

out/cljs/analyzer.js:4740: WARNING - incomplete alias created for namespace cljs.spec
var mchk = (function (){var and__6935__auto__ = cljs.spec;
                                                ^

Sep 26, 2016 7:18:00 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 0 error(s), 1 warning(s)
Successfully compiled "out/main.js" in 43.391 seconds.


 Comments   
Comment by Michael Glaesemann [ 26/Sep/16 6:28 PM ]

I came across this when upgrading Om from alpha44 to alpha45. The commit that changed the behavior moved to from cljs to cljc for server-side rendering support. (https://github.com/omcljs/om/commit/439802239fdfb95b143cde33df26be7801069bf2)

Test case: https://gist.github.com/grzm/0d2db1d1364daeb6118b610c2fc60178

António Nuno Monteiro pointed out:
https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/analyzer.cljc#L2666

            (let [mchk  #?(:clj  (some-> (find-ns 'clojure.spec)
                                   (ns-resolve 'macroexpand-check))
                           :cljs (and ^::no-resolve cljs.spec
                                      ^::no-resolve cljs.spec/macroexpand-check))




[CLJS-1784] Cleanup set creation functions Created: 20/Sep/16  Updated: 26/Sep/16

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

Type: Enhancement Priority: Minor
Reporter: Thomas Mulvaney Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File CLJS-1784.patch    
Patch: Code

 Description   

Use .fromArray for consistency/speed when handling zeroed IndexedSeqs.

Use reduce as the default construction path to take advantage of reducible collections.



 Comments   
Comment by Rohit Aggarwal [ 26/Sep/16 4:13 PM ]

Thomas Mulvaney, could you provide some benchmarks for the speed assertion? It would be nice to run it on Chrome/Firefox/Safari.





[CLJS-1790] Port CLJ-1935: Use multimethod dispatch value method lookup to take hierarchies into account in multi-spec Created: 21/Sep/16  Updated: 26/Sep/16  Resolved: 26/Sep/16

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

Type: Task Priority: Major
Reporter: David Nolen Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: newbie

Attachments: Text File CLJS-1790.patch    

 Description   

See Clojure commit: https://github.com/clojure/clojure/commit/522ba8b82ba6eb6c50284a211e7533db51363b8f



 Comments   
Comment by Lauri Oherd [ 25/Sep/16 4:53 AM ]

Code and Test

Comment by David Nolen [ 26/Sep/16 2:20 PM ]

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





[CLJS-1685] Incorrectly lazy subvec when start param is nil Created: 17/Jun/16  Updated: 26/Sep/16

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: 1.9.36
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Alf Kristian Støyle Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

ClojureScript 1.9.36 on Mac and Windows


Attachments: Text File cljs-1685.patch    

 Description   

subvec in ClojureScript does not fail when start param is nil. This is different than in regular Clojure.

In Clojure:

(def foo (subvec nil 1))
CompilerException java.lang.IndexOutOfBoundsException, compiling:(form-init4645269128697935824.clj:1:10) 
(def foo (subvec nil nil))
CompilerException java.lang.NullPointerException, compiling:(form-init4645269128697935824.clj:1:10)

In ClojureScript:

(def foo (subvec nil 1))
#object[Error Error: Index out of bounds]
   cljs.core/build-subvec (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:5316:16)
   Function.cljs.core.subvec.cljs$core$IFn$_invoke$arity$3 (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:5328:7)
   Function.cljs.core.subvec.cljs$core$IFn$_invoke$arity$2 (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:5326:7)
   cljs$core$subvec (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:5319:1)
=> nil
(def foo (subvec nil nil))
=> #'user/foo

foo is of course not usable after this:

foo
#object[Error Error: No protocol method IIndexed.-nth defined for type null: ]
   cljs.core/missing-protocol (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:264:4)


 Comments   
Comment by Joshua Miller [ 26/Sep/16 1:37 PM ]

Added fix and test.





[CLJS-1793] Few misplaced docstrings Created: 24/Sep/16  Updated: 24/Sep/16

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

Type: Defect Priority: Trivial
Reporter: Thomas Mulvaney Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File CLJS-1793.patch    

 Description   

A few docsctrings were placed after the binding form in the src/main/clojure/cljs/closure.clj namespace.






[CLJS-1682] :foreign-libs with module conversion does not works properly if it is used form deps.cljs Created: 13/Jun/16  Updated: 23/Sep/16  Resolved: 23/Sep/16

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: 1.9.36, 1.9.76
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Andrey Antukh Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: closure, compiler, foreign-libs
Environment:

Linux, openjdk8


Attachments: Text File CLJS-1682.patch    
Patch: Code

 Description   

When :foreign-libs is used for consume commonjs (or amd) modules from clojurescript using the `deps.cljs` mechanism, an unexpected "internal compiler error" is raised. When the same configuration is attached on the build script, everything works as expected.

Simple way to reproduce that, create sample directory tree:

mkdir tmp;
cd tmp;
mkdir -p src/testapp
mkdir -p src/vendor
touch src/testapp/core.cljs
touch src/vendor/greeter.js

Download the latest compiler or copy the recently build one from master:

wget https://github.com/clojure/clojurescript/releases/download/r1.9.36/cljs.jar

Create the sample cljs file:

;; tmp/src/testapp/core.cljs
(ns testapp.core
  (:require [cljs.nodejs :as nodejs]
            [greeter.core :as g]))

(nodejs/enable-util-print!)

(defn -main
  [& args]
  (println (g/sayHello "Ciri")))

(set! *main-cli-fn* -main)

Create the sample commonjs module:

"use strict";

exports.sayHello = function(name) {
  return `Hello ${name}!`;
};

Create the build script (that works):

;; tmp/build.clj
(require '[cljs.build.api :as b])

(b/build "src"
 {:main 'testapp.core
  :output-to "out/main.js"
  :output-dir "out"
  :target :nodejs
  :language-in  :ecmascript6
  :language-out :ecmascript5
  :foreign-libs [{:file "vendor/greeter.js"
                  :module-type :commonjs
                  :provides ["greeter.core"]}]
  :verbose true})

And compile this using the following command:

java -cp cljs.jar:src clojure.main build.clj

This will generate successfully the final artifact that can be successufully executed with node:

node out/main.js
# => "Hello Ciri!"

But, if you remove the `:foreign-libs` from the build script and create a new `src/deps.cljs` file
with the following content:

{:foreign-libs [{:file "vendor/greeter.js"
                 :module-type :commonjs
                 :provides ["greeter.core"]}]}

And try compile it:

$ java -cp cljs.jar:src clojure.main build.clj
Copying jar:file:/home/niwi/tmp/cljs.jar!/cljs/core.cljs to out/cljs/core.cljs
Reading analysis cache for jar:file:/home/niwi/tmp/cljs.jar!/cljs/core.cljs
Compiling out/cljs/core.cljs
Using cached cljs.core out/cljs/core.cljs
Copying jar:file:/home/niwi/tmp/cljs.jar!/cljs/nodejs.cljs to out/cljs/nodejs.cljs
Compiling out/cljs/nodejs.cljs
Compiling src/testapp/core.cljs
Copying jar:file:/home/niwi/tmp/cljs.jar!/cljs/nodejs.cljs to out/cljs/nodejs.cljs
Copying jar:file:/home/niwi/tmp/cljs.jar!/cljs/nodejscli.cljs to out/cljs/nodejscli.cljs
Copying jar:file:/home/niwi/tmp/cljs.jar!/goog/base.js to out/goog/base.js
Copying jar:file:/home/niwi/tmp/cljs.jar!/goog/string/string.js to out/goog/string/string.js
Copying jar:file:/home/niwi/tmp/cljs.jar!/goog/object/object.js to out/goog/object/object.js
Copying jar:file:/home/niwi/tmp/cljs.jar!/goog/string/stringbuffer.js to out/goog/string/stringbuffer.js
Copying jar:file:/home/niwi/tmp/cljs.jar!/goog/debug/error.js to out/goog/debug/error.js
Copying jar:file:/home/niwi/tmp/cljs.jar!/goog/dom/nodetype.js to out/goog/dom/nodetype.js
Copying jar:file:/home/niwi/tmp/cljs.jar!/goog/asserts/asserts.js to out/goog/asserts/asserts.js
Copying jar:file:/home/niwi/tmp/cljs.jar!/goog/array/array.js to out/goog/array/array.js
Copying file:/home/niwi/tmp/src/vendor/greeter.js to out/greeter.js
Exception in thread "main" java.lang.RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

null
  Node(SCRIPT): vendor/greeter.js:1:0
[source unknown]
  Parent: NULL, compiling:(/home/niwi/tmp/build.clj:3:1)
        at clojure.lang.Compiler.load(Compiler.java:7391)
        at clojure.lang.Compiler.loadFile(Compiler.java:7317)
        at clojure.main$load_script.invokeStatic(main.clj:275)
        at clojure.main$script_opt.invokeStatic(main.clj:335)
        at clojure.main$script_opt.invoke(main.clj:330)
        at clojure.main$main.invokeStatic(main.clj:421)
        at clojure.main$main.doInvoke(main.clj:384)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.lang.Var.invoke(Var.java:379)
        at clojure.lang.AFn.applyToHelper(AFn.java:154)
        at clojure.lang.Var.applyTo(Var.java:700)
        at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

[...]


 Comments   
Comment by Andrey Antukh [ 13/Jun/16 5:42 AM ]

Also happens with `cljs.jar` build from master.

Comment by Rohit Aggarwal [ 14/Jun/16 5:40 AM ]

[Compiler noob here]

Here is what is causing the issue:

In src/main/clojure/cljs/closure.clj in process-js-modules function, in the first case :foreign-libs is being set in opts and in the second failing case :ups-foreign-libs is being set in opts.

I am investigating the root of this.

Comment by Rohit Aggarwal [ 14/Jun/16 6:11 AM ]

A fix is to that set foreign-libs keyword in opts to a union of both foreign-libs and ups-foreign-libs.

I've verified that it works for both the above given examples. But I don't know enough about the compiler to propose this change.

Comment by Rohit Aggarwal [ 14/Jun/16 10:57 AM ]

Attaching patch with fixes this problem. The patch keeps the two sets of data (ups-foreign-libs, foreign-libs) separate.

I've run all the tests and they pass.

Comment by David Nolen [ 23/Sep/16 2:31 PM ]

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





[CLJS-1710] spec/double-in not implemented Created: 20/Jul/16  Updated: 23/Sep/16  Resolved: 23/Sep/16

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

Type: Defect Priority: Major
Reporter: Marshall Abrams Assignee: David Nolen
Resolution: Completed Votes: 1
Labels: cljs, newbie, spec
Environment:

Clojurescript 1.9.89



 Description   

spec/double-in is available in Clojure 1.9.0-alpha10, but doesn't seem to be implemented yet in Clojurescript as of 1.9.89. I also tried 1.9.76: not there either.

cljs.user=> (require '[cljs.spec :as s])
nil
cljs.user=> (s/valid? #(and (>= % 0.0) (<= % 1.0)) 1.0)
----  Compiler Warning on   <cljs form>   line:1  column:12  ----

  Use of undeclared Var cljs.spec/double-in

  1  (s/valid? (s/double-in :min 0.0 :max 1.0) 1.0)
                ^---

----  Compiler Warning  ----
#object[TypeError TypeError: Cannot read property 'call' of undefined]
nil

(Newbie ticket. Apologies if this is a dupe ticket or doesn't belong here. I couldn't find any tickets that seemed to mention this issue.)



 Comments   
Comment by David Nolen [ 23/Sep/16 2:22 PM ]

fixed https://github.com/clojure/clojurescript/commit/0ed939815738488efc2b627b8eeb3061a3c4dcd8





[CLJS-1767] Make spec explain printer pluggable Created: 31/Aug/16  Updated: 23/Sep/16  Resolved: 23/Sep/16

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

Type: Task Priority: Major
Reporter: David Nolen Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None


 Description   

Same as https://github.com/clojure/clojure/commit/99ab306f82620e6db6a978a5565d2ccd668c0798



 Comments   
Comment by David Nolen [ 23/Sep/16 2:05 PM ]

http://dev.clojure.org/jira/browse/CLJS-1787





[CLJS-1787] Make cljs.spec explain pluggable Created: 21/Sep/16  Updated: 23/Sep/16  Resolved: 23/Sep/16

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

Type: Task Priority: Major
Reporter: David Nolen Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: newbie


 Description   

See Clojure commit:

https://github.com/clojure/clojure/commit/99ab306f82620e6db6a978a5565d2ccd668c0798



 Comments   
Comment by David Nolen [ 23/Sep/16 2:03 PM ]

fixed https://github.com/clojure/clojurescript/commit/8399062f0179770580f53ac331485c5e944a773c





[CLJS-1666] Flag to optionally disable transit analysis cache encoding Created: 03/Jun/16  Updated: 23/Sep/16

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

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


 Description   

We need a flag to explicitly disable the transit encoding - this is to work around code that creates unencodeable forms for one reason or another. EDN had become more lax about encoding random Objects which allowed this stuff to go under the radar in the past.



 Comments   
Comment by Wilker Lúcio da Silva [ 06/Jun/16 9:10 PM ]

I'm having a compilation issue with ClojureScript 1.9.36, I'm writing an app that uses untangled and this file https://github.com/untangled-web/untangled-client/blob/f42088c84b059562a48455a71daa6e4ea08d286c/src/untangled/client/data_fetch.cljs fails to compile with Caused by: java.lang.RuntimeException: java.lang.Exception: Not supported: class cljs.tagged_literals.JSValue this issue doesn't happen with 1.9.14

Comment by David Nolen [ 06/Jun/16 10:06 PM ]

We should investigate whether just handling JSValue + other cases like clojure.lang.Var is good enough.

Comment by David Nolen [ 08/Jun/16 8:53 AM ]

JSValue encoding/decoding landed in master fixing part of the issue. Still need more information about the Var case however.





[CLJS-1563] :source-map option to cljs.build.api/build should take nil Created: 07/Feb/16  Updated: 23/Sep/16  Resolved: 23/Sep/16

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

Type: Enhancement Priority: Minor
Reporter: Isaac Cambron Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1563.patch    
Patch: Code

 Description   

It should be possible to specify nil or false when providing the :source-map option to cljs.build.api/build, for example, like this:

(build {...
        :optimizations :whitespace
        :source-map (when debug? "somepath.js.map")})

Currently that causes:

Exception in thread "main" java.lang.AssertionError: Assert failed: :source-map nil must specify a file in the same directory as :output-to "target/js/zs-background.js" if optimization setting applied
(or (nil? (:output-to opts)) (:modules opts) (string? source-map)), compiling:(/Users/isaac/code/zensight/client/cljs/build.clj:66:1)

Using false has the same behavior. The alternative of conditionally assoc ing the key in works just fine, but is a tad awkward. It seems reasonably straightforward to fix - need to change that assert to check the value in the map and double-check that it's checked properly downstream. Happy to submit a patch if you'll take it.



 Comments   
Comment by Isaac Cambron [ 07/Feb/16 10:18 AM ]

Apologies for the formatting; forgot that backtick stuff doesn't work in Jira.

Comment by Mike Fikes [ 08/Feb/16 5:05 PM ]

Reformatted description.

Comment by David Nolen [ 12/Feb/16 2:36 PM ]

Patch welcome.

Comment by António Nuno Monteiro [ 19/Sep/16 9:03 AM ]

Attached patch with fix.

Comment by David Nolen [ 23/Sep/16 1:42 PM ]

fixed https://github.com/clojure/clojurescript/commit/30ab498888bb228d29a80c6a268d9d8df96b36e6





[CLJS-1781] Add cljs.hash-map-test to self-parity tests Created: 19/Sep/16  Updated: 23/Sep/16  Resolved: 23/Sep/16

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

Type: Defect Priority: Minor
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1781.patch    
Patch: Code and Test

 Comments   
Comment by David Nolen [ 23/Sep/16 1:37 PM ]

fixed https://github.com/clojure/clojurescript/commit/5ad018ab442fd038c954e8996c7d6c0a456f2fe3





[CLJS-1785] Warn on reference to js/foo shadowed by local binding Created: 21/Sep/16  Updated: 23/Sep/16  Resolved: 23/Sep/16

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

Type: Enhancement Priority: Trivial
Reporter: Trevor Schmidt Assignee: David Nolen
Resolution: Completed Votes: 1
Labels: None
Environment:

OS X



 Description   

When a local binding shadows a JS global, and an attempt is made to access said global with js/foo, it would be nice to get a warning indicating that the global is inaccessible.

Example:

(defn simple-repro []
  (let [location (str js/location.pathname)]
    location))

Per discussion in Clojurians Slack, this is the same issue as http://dev.clojure.org/jira/browse/CLJS-833.

The previous issue was closed because the suggested solution was inadequate, but per discussion it seems appropriate to provide a warning so it is less surprising.



 Comments   
Comment by David Nolen [ 23/Sep/16 1:31 PM ]

fixed https://github.com/clojure/clojurescript/commit/00e46feb03e7c4e7784f6b0759762d537ea1daaa





[CLJS-1789] Port CLJ-1988: Extend coll-of to handle sequences Created: 21/Sep/16  Updated: 23/Sep/16  Resolved: 23/Sep/16

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

Type: Task Priority: Major
Reporter: David Nolen Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: newbie

Attachments: Text File cljs-1789.patch    

 Description   

See Clojure commit: https://github.com/clojure/clojure/commit/edf869a0fa56df3aa2503980af65931d76e2e00b



 Comments   
Comment by Joshua Miller [ 21/Sep/16 2:56 PM ]

Adds fix and test.

Comment by David Nolen [ 23/Sep/16 1:01 PM ]

fixed https://github.com/clojure/clojurescript/commit/7ef1ed8debc647ddef847ac85262b24bfe96c48a





[CLJS-1788] Port CLJ-2004: include retag in multi-spec form Created: 21/Sep/16  Updated: 23/Sep/16  Resolved: 23/Sep/16

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

Type: Task Priority: Major
Reporter: David Nolen Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: newbie

Attachments: Text File CLJS-1788.patch    

 Description   

See Clojure commit:

https://github.com/clojure/clojure/commit/5e83c2ab898fefe655ee45495d56d69a6bd10304



 Comments   
Comment by Lauri Oherd [ 23/Sep/16 11:52 AM ]

Code and Test

Comment by Lauri Oherd [ 23/Sep/16 11:57 AM ]

Is it possible to edit the ticket's Patch field in order to add the "Code and Test" value to it (as described on https://github.com/clojure/clojurescript/wiki/Patches page)?
I couldn't find the Patch field.

Comment by David Nolen [ 23/Sep/16 12:56 PM ]

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





[CLJS-1792] Can't load clojure.spec.test when clojure.test.check is unavailable Created: 23/Sep/16  Updated: 23/Sep/16

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

Type: Defect Priority: Major
Reporter: Arne Brasseur Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: spec
Environment:
Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
[org.clojure/clojure "1.9.0-alpha12"]
[org.clojure/clojurescript "1.9.229" :scope "provided"]


 Description   

Requiring clojure.spec.test results in an error, because it's looking for clojure.test.spec.

(ns foo.bar
  (:require [clojure.spec.test]))
Caused by: clojure.lang.ExceptionInfo: No such namespace: clojure.test.check, could not locate clojure/test/check.cljs, clojure/test/check.cljc, or Closure namespace "clojure.test.check" in file file:/home/arne/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/spec/test.cljs {:tag :cljs/analysis-error}

This problem goes away when adding org.clojure/test.check as a dependency.

This is not an issue in Clojure. An exception is only raised when calling a function that relies on test.check.






[CLJS-1791] :hierarchy option of defmulti is not used to determine if one dispatch value dominates on another Created: 22/Sep/16  Updated: 22/Sep/16

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

Type: Defect Priority: Major
Reporter: Andrey Zaytsev Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: bug

Attachments: Text File 0001-follow-up-on-CLJS-460-defmulti-ignores-optional-hier.patch    
Patch: Code and Test

 Description   

It leads to exception on method invocation.
Patch for similar issue CLJS-460 does not address conflicting dispatch values.






[CLJS-439] IEncodeClojure only works on same-context Objects Created: 11/Dec/12  Updated: 21/Sep/16  Resolved: 20/Jan/13

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

Type: Defect Priority: Minor
Reporter: Tom Jack Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

The default impl uses (identical? (type x) js/Object), but objects created in another JS context (e.g. another frame) will fail this test, since their constructor is a different js/Object. Thus js->clj is the identity on such objects.

I wonder if there are any related problems anywhere else, e.g. with protocols? This seems to be the only occurrence of js/Object.

Maybe this can be fixed by extending IEncodeClojure to object? I don't immediately see how to do that without incurring the option destructuring overhead recursively.



 Comments   
Comment by David Nolen [ 13/Dec/12 7:55 AM ]

I don't think this is something that ClojureScript should try to address at all. To me it seems similar to various classloader issues in JVM land.

Comment by Tom Jack [ 15/Dec/12 2:31 AM ]

OK, I don't disagree.

Comment by Sean Grove [ 17/Dec/12 12:33 AM ]

This is causing some unpleasantness, and I'm not aware of the classloader issues. Why check (identical? js/object x) instead of (goog.isObject x) on https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L6948 ?

Comment by Chris Granger [ 17/Dec/12 1:26 AM ]

this bit me as well and I can't see a downside to using goog.isObject. I agree with David about not going down a rabbit hole here, but I think we can do the "right thing" for free.

EDIT: I spoke too soon. Looks like native objects, like dom nodes would blow up in this scenario. Also, goog.isObject returns true on functions, but that would be easy enough to deal with.

Comment by Tom Jack [ 17/Dec/12 2:31 AM ]

I suppose extending to object would similarly cause trouble for dom nodes etc?

If you can get ahold of the js/Object from another frame, is it possible to extend IEncodeClojure to it?

Comment by David Nolen [ 21/Dec/12 5:50 PM ]

I have some experience with this stuff - it's a rabbit hole. There are many objects that can cross contexts for which we can provide no sensible equality guarantees. If you need to move data between JS contexts then use GClosure and stick to the basic JS data types. I'm inclined to close this one unless someone has a brilliant comprehensive solution that I'm not seeing right now.

Comment by David Nolen [ 20/Jan/13 12:52 AM ]

This one is tricky. Closing for now.

Comment by Richard Newman [ 21/Sep/16 12:03 PM ]

I just ran into this.

js->clj works perfectly in a Node environment.

It doesn't work in a Firefox add-on, where an object is created in the add-on code and processed by cljs code loaded through `require`.

This cost me quite a bit of debugging time, because of course it works fine when you test it inside the same source file, and works fine in Node, which is a much simpler JS environment.

JS engine documentation makes it very clear that you should not do comparisons against prototypes, because it's nonsensical:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_context_(e.g._frames_or_windows)

The naïve workaround with the current implementation — to convert a JS object to a cljs object in the calling context – is difficult, because of course the calling context is pure JS (so it doesn't even have a js->clj function!), and if it did, it would be a different cljs, and the same problem would occur elsewhere when handling that cljs object.

Using `(js->clj (.parse js/JSON (.stringify js/JSON o)))` is an expensive alternative, and doesn't work for rich objects (including JS's own Date type).

So much as it's tempting to say "too hard, wontfix", this makes building a non-trivial library in ClojureScript very inconvenient indeed.

Proposed solutions:

  • Provide a js->clj function that assumes that the input is a JS type, and converts it through sane JS-appropriate logic. E.g., it calls Array.isArray(o) to determine whether the input is an array. Object is the final fallback.
  • Adjust the existing js->clj function that inverts its test: checking whether the input is a ClojureScript type first (because of course they're all objects), and otherwise falling through correct JS type determination code.

For the moment I am going to write the former myself, because I don't have any more time to waste.

Comment by Richard Newman [ 21/Sep/16 3:59 PM ]

Here's an implementation that works for my purposes. Feel free to extend or incorporate this into ClojureScript under the EPL, MPL-2.0, or otherwise.

https://gist.github.com/rnewman/0de1869fdd1667f6b4960cd49fa6d813





[CLJS-1786] Add knob for controlling printing of namespaced maps Created: 21/Sep/16  Updated: 21/Sep/16

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

Type: Task Priority: Major
Reporter: David Nolen Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: newbie


 Description   

See these Clojure commits:

https://github.com/clojure/clojure/commit/d57b5559829be8e8b3dcb28a20876b32615af0cb
https://github.com/clojure/clojure/commit/b49c1984a1527d17951fbb23ddf9406805a1343f
https://github.com/clojure/clojure/commit/05a8e8b323042fa043355b716facaed6003af324






[CLJS-1783] Unify List creation code Created: 20/Sep/16  Updated: 20/Sep/16

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

Type: Enhancement Priority: Minor
Reporter: Thomas Mulvaney Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File CLJS-1783.patch    
Patch: Code

 Description   

There is some duplication and redundant functions around List creation.

In this patch a fromArray method was added to List, consistent with other persistent data structures in the code base.






[CLJS-1536] REPL def symbol init collision Created: 03/Jan/16  Updated: 19/Sep/16

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

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File CLJS-1536.patch    
Patch: Code and Test

 Description   

In a REPL, if you try def where the init is a local matching the symbol being defined, then analysis fails.

(let [x 1]
  (def x x))

This can be verified in script/noderepljs and you can see it is some bad interaction with REPL var emission because if :def-emits-var false is added to the script, things work.



 Comments   
Comment by Txus Bach [ 04/Jan/16 3:01 PM ]

Confirmed that evaluating this breaks:

(require 'clojure.tools.reader
         'cljs.analyzer
         'cljs.compiler)

(let [env '{:ns {:name cljs.user}
            :def-emits-var true
            :locals {}}]
  (->> "(let [x 1] (def x 3))"
       clojure.tools.reader/read-string
       (cljs.analyzer/analyze env)
       cljs.compiler/emit-str))

(When emitting, not when just analyzing.)

Removing `:def-emits-var true` makes the bug disappear.

Looking into how to fix it – any clues are welcome, it's my first time around the codebase

Comment by Txus Bach [ 04/Jan/16 3:45 PM ]

Seems that var-ast is returning nil, because resolve-var doesn't return a map with an :ns key. Not sure if this code should work, but it returns nil:

(let [env {:ns {:name 'cljs.user},
 :def-emits-var true,
 :locals
 {'x
  {:init
   {:op :constant,
    :env
    {:ns {:name 'cljs.user},
     :def-emits-var true,
     :locals {},
     :line nil,
     :column nil,
     :context :expr},
    :form 1,
    :tag 'number},
   :name 'x,
   :binding-form? true,
   :op :var,
   :env {:line nil, :column nil},
   :column nil,
   :line nil,
   :info {:name 'x, :shadow nil},
   :tag 'number,
   :shadow nil,
   :local true}}}]
  (ana/resolve-var env 'x))

Will continue tomorrow. It's so much fun!

Comment by António Nuno Monteiro [ 16/Aug/16 4:29 PM ]

Attached patch with fix and test.

Comment by Mike Fikes [ 16/Aug/16 6:27 PM ]

I tried António's patch with various expressions in the REPL and couldn't find a way to break it.

Comment by David Nolen [ 19/Sep/16 9:24 AM ]

Would like to address the fact that `((let [x 1] (defn x [] x))` does not appear to work in the REPL. I'm looking into it.

Comment by António Nuno Monteiro [ 19/Sep/16 9:28 AM ]

Yeah, that's weird. This is what I tested with and works:

cljs.user=> (let [x 1] (defn x [] x))
#'cljs.user/x
cljs.user=> (x)
1




[CLJS-1761] Allow parallel Transit analysis cache writes Created: 19/Aug/16  Updated: 19/Sep/16

Status: Reopened
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Mike Fikes Assignee: Mike Fikes
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File CLJS-1761.patch    

 Description   

With CLJS-1759, Transit analysis cache writes are being serialized. This ticket asks that analysis be done to find the root cause, so we can fix it and removed the workaround in CLJS-1759.



 Comments   
Comment by Francis Avila [ 19/Aug/16 1:53 PM ]

I suspect these lines in transit are a race condition:

https://github.com/cognitect/transit-java/blob/3f359c434264f675460bc2662dde2a1b2d8e9559/src/main/java/com/cognitect/transit/impl/WriterFactory.java#L74-L76

newHandlerCache is a cognitect.transit.impl.Cache instance, which is just a normal LinkedHashMap with size 10.

In between the containsKey() call and the get() call a cached item may have been evicted, causing the JsonEmitter to have a null map handler, causing the "Not supported: class java.lang.Integer" exception to bubble out of the emit() call inside write().

I think the fix is to call newHandlerCache.get(customHandlers) by itself and check for null instead of looking up twice. (I am not a seasoned Java dev, so I am not sure if concurrent reads are safe here without synchronization.) The synchronized block should probably also monitor the cache itself instead of the factory class.

Comment by Francis Avila [ 19/Aug/16 1:55 PM ]

Also, all of this is just from reading the code and your stacktrace, i.e., it is purely hypothesis.

Comment by Francis Avila [ 19/Aug/16 2:19 PM ]

On the other hand, the transit writer is created repeatedly with the same handler map instance, so I don't know why the write handler cache would ever have more than one entry (its limit is 10).

Comment by Mike Fikes [ 19/Aug/16 10:38 PM ]

Francis has logged a ticket against transit-java https://github.com/cognitect/transit-java/issues/20 and I've done some further experimentation and recorded what I found in that ticket.

Comment by Francis Avila [ 22/Aug/16 7:04 AM ]

This patch uses write-handler-map and read-handler-map to completely pre-assemble the transit handler maps and sidestep all handler cache construction caching. (I think this is a good thing to do even without these transit problems.)

If there are indeed races related handler construction and caching, this patch should sidestep them all and allow fully parallel use of transit.

Comment by David Nolen [ 16/Sep/16 1:48 PM ]

fixed https://github.com/clojure/clojurescript/commit/92459050162fce53312d9df7d7b5c703d2d992c2

Comment by Mike Fikes [ 16/Sep/16 7:47 PM ]

CLJS-1761.patch does not resolve this issue. With it applied the failures as described in CLJS-1759 occur.

Comment by Mike Fikes [ 16/Sep/16 8:02 PM ]

I have failed to create a repro for CLJS-1759 that does not involve any downstream tooling (and it also appears to require a multicore box). For reference and for the record, the specific steps used to reproduce the issue are at https://github.com/cognitect/transit-java/issues/20#issuecomment-241312648 (and, if you happen to have access to box that can repro, you can confirm that ClojureScript master with this patch doesn't resolve the issue by editing the project.clj in the referenced downstream project to use a locally-built ClojureScript master).

Comment by David Nolen [ 19/Sep/16 8:31 AM ]

Thanks for the confirmation that the issue is not resolved.





[CLJS-1765] Empty iterator for some hash maps with a nil key Created: 27/Aug/16  Updated: 19/Sep/16  Resolved: 19/Sep/16

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

Type: Defect Priority: Major
Reporter: Mike Fikes Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1765.patch     Text File CLJS-1765.patch     Text File CLJS-1765.patch    
Patch: Code and Test

 Description   

Two specific examples:

cljs.user=> (.hasNext (-iterator {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 nil 9}))
false
cljs.user=> (.hasNext (-iterator (hash-map nil 1))))
false

This can affect "user-level" code as follows:

cljs.user=> (sequence (map identity) {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 nil 9})
()
cljs.user=> (sequence (map identity) (hash-map nil 1))
()


 Comments   
Comment by Thomas Mulvaney [ 27/Aug/16 5:27 PM ]

I've attached a simple patch with some tests.

Comment by Mike Fikes [ 27/Aug/16 6:22 PM ]

Confirmed CA at http://clojure.org/community/contributors

Comment by Mike Fikes [ 27/Aug/16 6:35 PM ]

The first ^boolean in the form (or ^boolean (not seen) ^boolean (.hasNext root-tier)) could be omitted.

The patch passes unit tests for me (both JVM and self-host) and causes the correct output to appear for the examples

Comment by Thomas Mulvaney [ 28/Aug/16 4:05 AM ]

Thanks Mike Fikes, I omitted that boolean flag per your suggestion. Updated patch now attached.

Comment by David Nolen [ 14/Sep/16 3:40 PM ]

This patch needs a rebase.

Comment by Thomas Mulvaney [ 14/Sep/16 6:06 PM ]

Most recent patch is rebased.

Comment by David Nolen [ 16/Sep/16 1:30 PM ]

This ticket needs a rebase again. We should probably consider breaking up our core tests into individual namespaces.

Comment by Thomas Mulvaney [ 16/Sep/16 8:47 PM ]

I would be happy to put the tests in a new namespace. Does `src/test/cljs/cljs/hash_map_test.cljs` sound sensible?

Comment by Thomas Mulvaney [ 18/Sep/16 8:27 PM ]

Newest patch has been rebased and tests were split out into the namespace I proposed in previous comment.

Comment by David Nolen [ 19/Sep/16 8:29 AM ]

fixed https://github.com/clojure/clojurescript/commit/7923f80fd50b3a7d1f808dd746758a1375a8e25d





[CLJS-1748] Nth doesn't throw error for strings or arrays Created: 15/Aug/16  Updated: 19/Sep/16  Resolved: 19/Sep/16

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

Type: Defect Priority: Minor
Reporter: Thomas Mulvaney Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1748.patch     Text File CLJS-1748.patch    
Patch: Code and Test

 Description   

Calling nth on a string or array with an out of bounds index should throw an error but returns an empty string or nil.

(nth "012" 3) -> ""
(nth (array 0 1 2) 3) nil

Calling nth on a string or array with a negative index and a not-found value returns an empty string or nil.

(nth "012" -1 :not-found) -> ""
(nth (array 0 1 2) -1 :not-found) nil



 Comments   
Comment by David Nolen [ 16/Sep/16 2:11 PM ]

This one needs a rebase.

Comment by Thomas Mulvaney [ 18/Sep/16 8:45 PM ]

Rebased patch attached. Also fixed inconsistent capitalisation on some of the errors being thrown.

Comment by David Nolen [ 19/Sep/16 8:25 AM ]

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





[CLJS-1715] Self-host: Symbols in cljs.spec.test/instrument Created: 27/Jul/16  Updated: 16/Sep/16

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

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: Mike Fikes
Resolution: Unresolved Votes: 0
Labels: bootstrap

Attachments: Text File CLJS-1715-2.patch     Text File CLJS-1715.patch    
Patch: Code

 Description   

For bootstrapped ClojureScript, within cljs.spec.test/instrument:

1. There is a use of speced-vars that conditionally needs the $macros suffix (analogous to CLJS-1656).
2. The references to the runtime fns instrumentable-syms and distinct-by need to be qualified (otherwise their expansions use $macros.



 Comments   
Comment by Mike Fikes [ 10/Aug/16 4:12 PM ]

Previous patch no longer applies. Attaching a rebased patch. This patch is still relevant to master.

Comment by David Nolen [ 16/Sep/16 2:12 PM ]

Needs a rebase.

Comment by David Nolen [ 16/Sep/16 2:23 PM ]

Does CLJS-1773 address this?





[CLJS-1696] Alias clojure.spec.gen => cljs.spec.impl.gen Created: 29/Jun/16  Updated: 16/Sep/16

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

Type: Defect Priority: Trivial
Reporter: Shaun LeBron Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None

Attachments: Text File CLJS-1696.patch    

 Description   

A special case for http://dev.clojure.org/jira/browse/CLJS-1692 to correctly alias clojure.spec.gen.



 Comments   
Comment by Shaun LeBron [ 29/Jun/16 12:02 PM ]

code and test

Comment by David Nolen [ 29/Jun/16 2:04 PM ]

I'm not excited about special casing this one. I'd rather wait to see if people actually use this namespace frequently enough for this to be desirable.

Comment by Shaun LeBron [ 29/Jun/16 10:37 PM ]

yeah, i guess the question is who should be responsible for handling this special case-- the user with reader conditionals or the compiler with this patch.

for extra context, I asked about this last week in slack: https://clojurians.slack.com/archives/clojurescript/p1466866626001218

Comment by Oliver George [ 13/Aug/16 4:41 AM ]

Just to bump this, I see references to requiring clojure.spec.gen in a few places now. The Clojure spec guide mentions it in project setup for generators, and the Clojure spec screencast on customizing generators.

One possibly related point. It seems necessary to require `clojure.test.check` in order for requiring `cljs.spec.impl.gen` to work.





[CLJS-1773] Self-host: Don't resolve unqualified symbols / keywords with $macros Created: 05/Sep/16  Updated: 16/Sep/16  Resolved: 16/Sep/16

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

Type: Enhancement Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bootstrap

Attachments: Text File CLJS-1773.patch    

 Description   

Background: Since, in self-hosted ClojureScript, macro namespaces are compiled as ClojureScript, a $macros suffix is appended to macros namespace names in order to differentiate them from same-named runtime namespaces. As a concrete example: The foo.core runtime namespace will be processed normally, but the same, when compiled as a macro namespace is internally renamed to be foo.core$macros.

A consequence is that the internal $macros suffix surfaces in a few places where it is undesired. Specifically this ticket focuses on the cases of unqualified symbols subject to syntax-quote resolution and namespaced keywords that use the :: construct (as in ::bar). When these are used in macro namespaces, and then compiled with bootstrapped ClojureScript, a symbol like `baz would turn in to foo.core$macros/baz, and a keyword like ::bar would turn in to :foo.core$macros/bar.

In the case of symbols, it might be the case that the user wanted the symbol to refer to a var in the runtime namespace, in which case foo.core/baz is desired. And, even if the desire was that it end up referring to a macro named baz, then foo.core/baz works just fine. To achieve this, when porting regular ClojureScript code to be compatible with bootstrapped ClojureScript, one common pattern is the need to qualify symbols inside of syntax-quote scope so that they don't end up with the $macros suffix.

The same, parallel arguments essentially go for keywords: You want ::bar to turn into :foo.core/bar in both JVM and bootstrapped ClojureScript, and today, to achieve that, you must qualify those kinds of keywords when they appear in macros namespaces.

This ticket asks that when unqualified symbols in syntax quote are resolved and when the analogous thing occurs for keywords, that the $macros suffix be avoided as experience has shown now that it is practically always not the thing that you want (and perhaps also not correct from the desired language semantics.)



 Comments   
Comment by David Nolen [ 16/Sep/16 2:20 PM ]

fixed https://github.com/clojure/clojurescript/commit/7e90ad51452ec5edd8ee7f2b7af9c7e7fb759c97





[CLJS-1750] With `:language-out :ecmascript5-strict` goog.global is undefined Created: 15/Aug/16  Updated: 16/Sep/16  Resolved: 16/Sep/16

Status: Resolved
Project: ClojureScript
Component/s: None
Affects Version/s: 1.9.76
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Dusan Maliarik Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: closure


 Description   

When using `:language-out :ecmascript5-strict` the compiled code ends up in a wrapper where `this` resolves to `undefined`. This break goog/base.js where `this` is assigned to `goog.global`.



 Comments   
Comment by David Nolen [ 15/Aug/16 2:34 PM ]

This doesn't seem like a bug but rather a faithful interpretation of strict mode - see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.





[CLJS-1764] Double warning for undeclared Var Created: 26/Aug/16  Updated: 16/Sep/16

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

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


 Description   

A regression occurred where an undeclared Var in a {{require}}d file causes two diagnostics:

$ more src/foo/core.cljs
(ns foo.core)

(def x 2)

abc
$ rm -rf .cljs_node_repl
$ java -cp cljs-1.9.227.jar:src clojure.main -m cljs.repl.node
ClojureScript Node.js REPL server listening on 52749
To quit, type: :cljs/quit
cljs.user=> *clojurescript-version*
"1.9.227"
cljs.user=> (require 'foo.core)
WARNING: Use of undeclared Var foo.core/abc at line 5 /Users/mfikes/Desktop/src/foo/core.cljs
WARNING: Use of undeclared Var foo.core/abc at line 5 /Users/mfikes/Desktop/src/foo/core.cljs
nil
cljs.user=> :cljs/quit
$ rm -rf .cljs_node_repl
$ java -cp cljs-1.9.211.jar:src clojure.main -m cljs.repl.node
ClojureScript Node.js REPL server listening on 56704
To quit, type: :cljs/quit
cljs.user=>  *clojurescript-version*
"1.9.211"
cljs.user=> (require 'foo.core)
WARNING: Use of undeclared Var foo.core/abc at line 5 /Users/mfikes/Desktop/src/foo/core.cljs
nil
cljs.user=> :cljs/quit


 Comments   
Comment by David Nolen [ 16/Sep/16 2:04 PM ]

If somebody wants to do a git bisect to sort this one out, that would be awesome





[CLJS-1770] goog-defines broken for integers Created: 01/Sep/16  Updated: 16/Sep/16  Resolved: 16/Sep/16

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

Type: Defect Priority: Minor
Reporter: Tom Connors Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: closure

Attachments: Text File CLJS-1770.patch    

 Description   

Using goog-define with integer values results in cljs.closure/make-options attempting to call .setDefineToIntegerLiteral on the compiler-options object. That method does not exist; the correct method is .setDefineToNumberLiteral. Note however that calls to .setDefineToNumberLiteral will fail when the value is a long; it might make sense to always use .setDefineToDoubleLiteral when the value is a number. Integers passed to .setDefineToDoubleLiteral remain integers in the output javascript, so it seems harmless enough to do it that way.



 Comments   
Comment by Tom Connors [ 02/Sep/16 8:55 AM ]

Patch for using setDefineToDoubleLiteral for all numbers.

Comment by David Nolen [ 16/Sep/16 2:01 PM ]

fixed https://github.com/clojure/clojurescript/commit/1d8964ea632fbb3c775cbacb1f11807fbdfe9e72





[CLJS-1600] Destructuring defprotocol fn args causes defrecord impls to silently fail Created: 11/Mar/16  Updated: 16/Sep/16  Resolved: 16/Sep/16

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

Type: Defect Priority: Minor
Reporter: James Henderson Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1600-2.patch     Text File CLJS-1600-3.patch     Text File CLJS-1600.patch    
Patch: Code and Test

 Description   
(defprotocol IFoo
  (foo-fn [_ {:keys [a b] :as args}]))

(defrecord Foo []
  IFoo
  (foo-fn [_ {:keys [a b] :as args}]
    args))

(foo-fn (->Foo) {:a 1, :b 2})

returns

{:keys [1 2], :as {:a 1, :b 2}}

in CLJS, rather than

{:a 1, :b 2}

as Clojure does.

Redefining IFoo to

(defprotocol IFoo
  (foo-fn [_ args]))

causes the issue to go away.

While it's quite a minor bug, it was quite a hard one to track down, in practice - I didn't think to look at the protocol definition when the record was breaking, even after having used ClojureScript for a good few years!

Cheers,

James



 Comments   
Comment by António Nuno Monteiro [ 30/Jul/16 4:01 PM ]

Attached patch with fix and test.

Comment by Mike Fikes [ 31/Jul/16 1:54 PM ]

Hey António, the patch fails script/test-self-parity owing to the direct use of let and if-not outside of syntax-quote scope on line 1939. If you qualify them as core/let and core/if-not, then the tests pass in bootstrap.

Comment by António Nuno Monteiro [ 31/Jul/16 5:01 PM ]

Thanks for the feedback, Mike. I might have forgotten to run the self-parity test.
Attached CLJS-1600-2.patch which passes all tests.

Comment by David Nolen [ 16/Sep/16 1:40 PM ]

fixed https://github.com/clojure/clojurescript/commit/309de72e7204d53863a95cd6fa33424c9c9e269f





[CLJS-1335] resolve-macro-var: information missing for macros Created: 12/Jul/15  Updated: 16/Sep/16  Resolved: 16/Sep/16

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

Type: Defect Priority: Major
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bootstrap
Environment:

https://github.com/swannodette/cljs-bootstrap


Attachments: Text File CLJS-1335.patch    
Patch: Code

 Description   

In bootstrapped ClojureScript, if you resolve-var on a function, you get lots of information, but resolve-macro-var doesn't work for macros. (The only reason I have any expectation for this to work is that it appears to do so in ClojureScript JVM).

cljs-bootstrap.core=> (with-compiler-env cenv (ana/resolve-macro-var (ana/empty-env) 'or)))
nil

But:

cljs-bootstrap.core=> (with-compiler-env cenv (ana/resolve-var (ana/empty-env) 'map)))
{:protocol-inline nil, :meta {:file "cljs/core.cljs", :end-column 10, :top-fn {:variadic true, :method-params ([f] [f coll] [f c1 c2] [f c1 c2 c3]), :arglists-meta (nil nil nil nil nil), :max-fixed-arity 4, :arglists ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])}, :column 7, :line 4128, :end-line 4128, :arglists (quote ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])), :doc "Returns a lazy sequence consisting of the result of applying f to\n  the set of first items of each coll, followed by applying f to the\n  set of second items in each coll, until any one of the colls is\n  exhausted.  Any remaining items in other colls are ignored. Function\n  f should accept number-of-colls arguments. Returns a transducer when\n  no collection is provided."}, :ns cljs.core, :name cljs.core/map, :variadic true, :file "cljs/core.cljs", :end-column 10, :top-fn {:variadic true, :method-params ([f] [f coll] [f c1 c2] [f c1 c2 c3]), :arglists-meta (nil nil nil nil nil), :max-fixed-arity 4, :arglists ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])}, :method-params ([f] [f coll] [f c1 c2] [f c1 c2 c3]), :protocol-impl nil, :arglists-meta (nil nil nil nil nil), :column 1, :line 4128, :end-line 4128, :max-fixed-arity 4, :fn-var true, :arglists ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]), :doc "Returns a lazy sequence consisting of the result of applying f to\n  the set of first items of each coll, followed by applying f to the\n  set of second items in each coll, until any one of the colls is\n  exhausted.  Any remaining items in other colls are ignored. Function\n  f should accept number-of-colls arguments. Returns a transducer when\n  no collection is provided."}

As an aside:

cljs-bootstrap.core=> (with-compiler-env cenv (ana/resolve-var (ana/empty-env) 'or)))
{:name cljs.core/or, :ns cljs.core}


 Comments   
Comment by Andrea Richiardi [ 26/Dec/15 3:06 PM ]

I have a bit had a look at this and cljs.analyzer.api/resolve has the best approach, trying first resolve-var and then resolve-macro-var. At the moment this behavior is duplicated in both replumb and planck. It would be great to have that part of cljs.analyzer.api, and maybe others, ported to cljs.js. Thoughts?

Comment by Andrea Richiardi [ 26/Dec/15 3:29 PM ]

Actually in replumb at the moment I had to do something like:

[DELETED]

But it is just a workaround and probably you guys have a better approach to it.

Comment by Andrea Richiardi [ 26/Dec/15 5:52 PM ]

In replumb at the moment I had to merge the two maps, giving precedence to ana/resolve-var:

(defn resolve
  "From cljs.analyzer.api.clj. Given an analysis environment resolve a
  var. Analogous to clojure.core/resolve"
  [opts env sym]
  ;; AR - we need to merge because ana/resolve-var sometimes returns more
  ;; info than ana/resolve-macro-var, sometimes not
  (merge (ana/resolve-macro-var env sym) (ana/resolve-var env sym ana/confirm-var-exist-warning)))
Comment by António Nuno Monteiro [ 02/Sep/16 9:27 AM ]

Attached patch with fix.

Comment by David Nolen [ 16/Sep/16 1:35 PM ]

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





[CLJS-1633] Improve error associated with invalid foreign-libs :file path Created: 26/Apr/16  Updated: 16/Sep/16  Resolved: 16/Sep/16

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

Type: Enhancement Priority: Minor
Reporter: Oliver George Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1633.patch    
Patch: Code

 Description   

The current error reported when :advanced compiling with an invalid :foreign-libs :file path is effectively (slurp nil):

Caused by: java.lang.IllegalArgumentException: Cannot open <nil> as a Reader.

With a small patch this could be improved to provide a specific message and relevant context, something like:

Caused by: clojure.lang.ExceptionInfo: Unable to resolve url for foreign-deps source {:foreign true, :url nil, :source-url nil, :provides ["cljsjs.example-thing"], :requires (), :lines nil, :source-map nil, :file "broken-path-to-example-thing.js"}

I've created a simple repo based on the mies template to demonstrate the problem. Note that core.cljs requires the foriegn-lib which is defined in deps.clj (but with an invalid :file path). scripts/release.clj shows current behaviour. scripts/release-with-patch.clj shows proposed behaviour.

https://github.com/condense/apr26-foreign-libs-path-error.core.git

Below shows an isolated fix to cljs.closure/foreign-deps-str which checks for a nil url. An alternative approach might be to check at the point where the source maps are prepared (something like (assert (or url url-min) "xxx")) but this would be more likely to have side effects.

(defn foreign-deps-str [opts sources]
  (letfn [(to-js-str [ijs]
            (if-let [url (or (and (#{:advanced :simple} (:optimizations opts))
                                  (:url-min ijs))
                             (:url ijs))]
              (slurp url)
              (throw (ex-info "Unable to resolve url for foreign-deps source" ijs))))]
    (str (string/join "\n" (map to-js-str sources)) "\n")))

I'd be happy to prepare a patch if this seems like the right approach. Have signed contributor agreement.



 Comments   
Comment by David Nolen [ 06/May/16 1:56 PM ]

A patch for this small enhancement is welcome.

Comment by António Nuno Monteiro [ 30/Jul/16 4:38 PM ]

Attached patch with fix.

Comment by David Nolen [ 16/Sep/16 1:28 PM ]

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





[CLJS-1775] `get` with `nil` returns as if `get` with `0` Created: 12/Sep/16  Updated: 16/Sep/16  Resolved: 16/Sep/16

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

Type: Defect Priority: Major
Reporter: James Tyler Solomon Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1775.patch    
Patch: Code and Test

 Description   

Calling `(get "test" nil)` returns `"t"` whereas previously it would return `nil`, as is the case in clojure.



 Comments   
Comment by António Nuno Monteiro [ 12/Sep/16 3:52 PM ]

Attached patch with fix and test.

Comment by David Nolen [ 14/Sep/16 3:36 PM ]

This patch needs a rebase it seems.

Comment by António Nuno Monteiro [ 14/Sep/16 3:42 PM ]

Replaced the patch with a rebased version.

Comment by Thomas Mulvaney [ 14/Sep/16 6:12 PM ]

Would it not be better to check if k is an integer rather than non-nil value when calling get on indexed collections?

Comment by António Nuno Monteiro [ 14/Sep/16 6:23 PM ]

It's not really how Clojure works, AFAICT:

boot.user=> (get "asd" 1.7)
\s
Comment by David Nolen [ 16/Sep/16 1:23 PM ]

fixed https://github.com/clojure/clojurescript/commit/9cb8da1d82078cfe21c7f732d94115867f455a0a





[CLJS-1780] Records without extmap fail to iterate Created: 15/Sep/16  Updated: 16/Sep/16  Resolved: 16/Sep/16

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

Type: Defect Priority: Major
Reporter: Thomas Mulvaney Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1780.patch    
Patch: Code and Test

 Description   

Calling hasNext on a Record with no extmap fails.



 Comments   
Comment by David Nolen [ 16/Sep/16 1:11 PM ]

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





[CLJS-1774] Self-host: Report filenames in warns in test-self-parity Created: 07/Sep/16  Updated: 14/Sep/16  Resolved: 14/Sep/16

Status: Resolved
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bootstrap

Attachments: Text File CLJS-1774.patch    
Patch: Code

 Description   

When running script/test-self-parity, make use of the new feature introduced with CLJS-1515 to add the capability of reporting filenames when diagnostics are emitted.

For example, you currently see

WARNING: baz is a single segment namespace at line 1

when running script/test-self-parity while script/test gives more info for the same diagnostic:

WARNING: baz is a single segment namespace at line 1 src/test/cljs/baz.cljs


 Comments   
Comment by David Nolen [ 14/Sep/16 3:37 PM ]

fixed https://github.com/clojure/clojurescript/commit/5f4ee993bcc39c055bdc05bc16d70f8fc8b02263





[CLJS-1778] cljs.spec.test/check only accepts literal syms, unlike clojure.spec.test/check Created: 14/Sep/16  Updated: 14/Sep/16  Resolved: 14/Sep/16

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

Type: Defect Priority: Major
Reporter: Jannis Pohlmann Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

As of commit https://github.com/clojure/clojurescript/commit/d0be39660f3a65422c3de6a774ceec0b6a863ee2, ClojureScript's implementation of `cljs.spec.test/check` only accepts a literal sym or a literal collection of syms as its inputs, e.g.

(cljs.spec.test/check 'some.ns/foo)
(cljs.spec.test/check '[some.ns/foo some.ns/bar])

It does not allow input syms to be passed in as a named value or to be generated (e.g. by filtering all checkable syms). So the following will fail:

(def test-syms '[some.ns/foo some.ns/bar])
(cljs.spec.test/check test-syms)
;; Results in an "`Unable to resolve symbol: test-syms`" error.

(cljs.spec.test/check (filter in-some-ns? (cljs.spec.test/checkable-syms)))
;; Results in an "`Unable to resolve symbol: filter`" error - I think.

This is different from the behavior of `clojure.spec.test/check` in Clojure, where all of the above are fine. Is this a bug or a deliberate difference?



 Comments   
Comment by David Nolen [ 14/Sep/16 3:35 PM ]

This is just how it works. Most of the clojure.spec.test/check must necessarily be implemented as macros.





[CLJS-1779] keyword 2-arity constructor accepts anything for both parameters which leads to different hashing Created: 14/Sep/16  Updated: 14/Sep/16  Resolved: 14/Sep/16

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

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


 Description   
(keyword 'app "foo")
(keyword "app" "foo")

Will produce different hash codes.



 Comments   
Comment by David Nolen [ 14/Sep/16 3:05 PM ]

fixed https://github.com/clojure/clojurescript/commit/5ac08cc0d5524e429200b1f9e68d27a5c07d5c3f





[CLJS-1777] `module` undefined when using `:module-type :commonjs` Created: 14/Sep/16  Updated: 14/Sep/16

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

Type: Enhancement Priority: Major
Reporter: Arne Brasseur Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

The Google Closure Compiler support for CommonJS modules rewrites `exports` and `module.exports`, but not `module`. Many libraries try to detect the module type (CommonJS) by checking the type of `module`, e.g. this is taken from D3.

```
typeof exports === 'object' && typeof module !== 'undefined'
```

This becomes

```
goog.provide('module$resource$d3')
typeof module$resource$d3 === 'object' && typeof module !== 'undefined'
```

Because `module` is undefined this fails, and nothing gets exported.

This seems like something Google Closure should address.

Alternatives would include injecting some code that defines `module` (`var module={}`) or munging `typeof module` to `"object"`.



 Comments   
Comment by Arne Brasseur [ 14/Sep/16 6:41 AM ]

To test

curl https://d3js.org/d3.v4.js > d3.js

Compiler options

:foreign-libs [{:file "d3.js"
:provides ["d3"]
:module-type :commonjs}]

Code

(:require '[d3])
(d3/select "#app")

Comment by Arne Brasseur [ 14/Sep/16 8:32 AM ]

Seems this exact case was already documented on Maria Geller's blog: http://mneise.github.io/posts/2015-07-08-week-6.html

Comment by Arne Brasseur [ 14/Sep/16 9:04 AM ]

Did some more digging, the issue is that thanks to http://dev.clojure.org/jira/browse/CLJS-1312 Closure Compiler tries to deal with UMD syntax, but there's no single definition of what UMD really looks like. Two popular tools (rollup and webpack) generate code that is not correctly recognized. This is what rollup generates

(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
  (factory((global.d3 = global.d3 || {})));
}(this, (function (exports) { 'use strict';

This is what webpack generates

(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory(require("react"), require("react-dom"));
	else if(typeof define === 'function' && define.amd)
		define(["react", "react-dom"], factory);
	else if(typeof exports === 'object')
		exports["ReactDataGrid"] = factory(require("react"), require("react-dom"));
	else
		root["ReactDataGrid"] = factory(root["React"], root["ReactDOM"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE

This will require changes to ProcessCommonJSModulesTest, similar to https://github.com/google/closure-compiler/commit/aa0a99cf380b05b2185156735d023b6fa78ec4ac





[CLJS-1776] Add fixed arities for mapcat Created: 13/Sep/16  Updated: 13/Sep/16

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: 1.9.76
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Robert C Faber Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: performance

Attachments: Text File CLJS_1776__Add_fixed_arities_for_mapcat.patch     Text File CLJS-1776.patch    
Patch: Code

 Description   

Following the pattern of map, this patch adds three fixed arities for mapcat.



 Comments   
Comment by Alex Miller [ 13/Sep/16 10:25 AM ]

Presumably this is to improve performance. Please include a benchmark showing the difference.





[CLJS-1772] Dependency index can incorrectly add `.cljc` files instead of `.cljs` if both are present Created: 02/Sep/16  Updated: 03/Sep/16  Resolved: 03/Sep/16

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

Type: Defect Priority: Major
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1772.patch    

 Comments   
Comment by António Nuno Monteiro [ 02/Sep/16 10:09 PM ]

Attached patch with fix.

Comment by David Nolen [ 03/Sep/16 7:37 AM ]

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





[CLJS-1627] jsdoc parsing fails to recognize union types, breaking resolution Created: 18/Apr/16  Updated: 02/Sep/16

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: 1.7.228
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Patrick Killean Assignee: David Nolen
Resolution: Unresolved Votes: 0
Labels: patch

Attachments: Text File CLJS-1627-4.patch     Text File CLJS-1627-5.patch    
Patch: Code and Test

 Description   

The Closure Spec For Union Types states that parentheses are necessary for union type expressions. Trying this ...

(defn foo
  "@param {(IBar|IMap)} x"
  [x] 
  ...)

Raises a Closure Error :

...ERROR - Bad type annotation. expected closing }
* @param {user.(IBar|user.IMap)}

This is because comp/resolve-types treats the parentheses as a part of the type tokens and incorrect var resolution occurs as a result. In addition, the compiler emits multiple resolved types separated by "|" characters but does not enclose them in parentheses to create a valid union type.



 Comments   
Comment by Patrick Killean [ 18/Apr/16 4:36 PM ]

This patch includes:

  • comp/resolve-types now removes parentheses when present and emits them when >1 type is detected. This makes parenthesis use optional and existing code remains unbroken (with the added benefit that it may work now)
  • changes to comp/resolve-type
    1. checks for js globals like document or window which are recognized by closure
    2. allows dot.delimited.forms to pass through so we can use types defined in externs and avoid unnecessary resolution
    3. uses ana/resolve-existing-var with a "unresolved jsdoc type" warning
    4. checks if a resolved var is a protocol and warns otherwise. This is more informative than Closure's standard unrecognized type error
  • a test for comp/resolve-types
Comment by David Nolen [ 21/Apr/16 12:45 PM ]

Thanks will try to look more closely at this tomorrow.

Comment by David Nolen [ 23/Apr/16 2:03 PM ]

The patch is getting there, please remove the `js-doc-type` meta stuff. Just extend the signature of resolve-existing-var to take an additional parameter - the confirm-var-exists handler.

Comment by Patrick Killean [ 09/May/16 4:58 PM ]

CLJS-1627-1.patch:
resolve-existing-var now has an additional arity that accepts a missing-var handler passed to confirm-existing-var

Comment by Patrick Killean [ 10/May/16 6:16 AM ]

This has revealed a problem where deftype + defrecord using Object protocols emit resolved names when really they shouldn't. For example : "@implements {cljs.core.async.impl.timers.Object}" --> Bad Type Annotation

Since Object is a special case simply excluding it from the comments should fix it. Another patch incoming

Comment by Patrick Killean [ 10/May/16 7:42 AM ]

CLJS-1627-2.patch:
The emit* methods for deftype and defrecord now filter out Object protocols.

This produced an interesting result! With no more bad type annotations, static analysis can now proceed... and it has alot to say. Theres all kinds of info now about arity discrepencies (particularly cljs.core.IndexedSeq), type mismatches, and more. It even includes a type coverage percentage. Lots to parse here but very cool.

Comment by Patrick Killean [ 18/May/16 4:26 PM ]

CLJS-1627-3.patch:

  • fix require extern
  • add type application support for Array & Object
  • GC likes uppercase for Object & Array, lowercase for string, number.
  • support for explicit nullable types, variable typed arg
  • function type context modifiers this + new

Missing is the GC 'record type' . It also may be useful to fill out the node externs for common types

Comment by Patrick Killean [ 20/May/16 11:42 AM ]

CLJS-1627-4.patch:

  • fix a few problems in last patch
  • add record type support. Everything here should be covered
Comment by Patrick Killean [ 02/Sep/16 8:21 AM ]

update patch





[CLJS-1771] Add helper for converting ex-info to js/Error Created: 02/Sep/16  Updated: 02/Sep/16

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: 1.9.76
Fix Version/s: None

Type: Enhancement Priority: Trivial
Reporter: Artem Yarulin Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: ex-info


 Description   

ex-info/ex-data/ex-message didn't get a lot of attention in CLJS community, still I find quiet often (js/Error. "Err"). I guess the main reason is that we cannot pass ex-info object back to JS world, clj->js doesn't work in this case. We can solve it by adding helper like ex->js which will convert ex-info backward to js/Error.

What do you think about such enhancement? I can add patch later if you would find it useful






[CLJS-1769] Use reduce pathway for arrays in js->clj Created: 01/Sep/16  Updated: 01/Sep/16

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

Type: Enhancement Priority: Trivial
Reporter: Thomas Mulvaney Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File CLJS-1769.patch    
Patch: Code

 Description   

Currently js->cljs uses `(vec (map some-fn some-js-array))` on arrays. By using `(mapv some-fn some-js-array)` we take advantage of array-reduce and avoid a lazy-sequence.






[CLJS-1768] cljs.spec perf tweaks Created: 31/Aug/16  Updated: 31/Aug/16

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

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


 Description   

Same as the following commits:

https://github.com/clojure/clojure/commit/de6a2b528a18bcb4768e82d0d707d2cab26268a6
https://github.com/clojure/clojure/commit/defa7b8ef268ea2b8772658ade2010ca5ad00dc4






[CLJS-901] Protocolize compiler access to the file system Created: 03/Dec/14  Updated: 28/Aug/16

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

Type: Task Priority: Minor
Reporter: David Nolen Assignee: Mike Fikes
Resolution: Unresolved Votes: 3
Labels: None


 Description   

Currently builds are based on files on disk. It is desirable to be able to instead get in memory builds, WebDAV based builds, S3 based builds, etc. Many of these alternative strategies are not in scope for the ClojureScript compiler but this does not mean we should not supply the needed hooks for users to control the behavior.



 Comments   
Comment by Thomas Heller [ 03/Dec/14 9:31 AM ]

This and some other issues opened recently (CLJS-900, CLJS-851, CLJS-899, ...) have some overlap with what I have done in shadow-build [1]. Memory based builds are actually already possible cause it will only touch the disk when asked to, although the API could use some cleanup.

Anyways, might be worthwhile to coordinate these efforts to make CLJS more accessible for everyone.

[1] https://github.com/thheller/shadow-build

Comment by Alan Dipert [ 04/Feb/15 11:36 AM ]

I too think it would be totally awesome to have builds based on sources from disparate places.

One alternative in this spirit I have been thinking about is a "SourceSet" approach. The idea is, instead of teaching CLJS how to consume various place-types directly via protocols, provide an API for building a "SourceSet" value and also a build function that takes the SourceSet as input. I imagine the SourceSet in its simplest form as a map of namespaces to string sources.

With a value to represent sources that is place-agnostic and immutable, 3rd party tools can consume/emit/transform these values before invoking a compile without knowledge or interest in CLJS internals. Conversely CLJS need not be concerned with how SourceSets are constructed.

This whole idea is inspired by boot's FileSets, which work basically the same but can't have the "it fits in memory" assumption.





[CLJS-1766] Set literals in REPL end up reified as ArrayMap backed PersistentHashSets. Created: 28/Aug/16  Updated: 28/Aug/16

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

Type: Defect Priority: Minor
Reporter: Thomas Mulvaney Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: repl


 Description   

Entering a set literal in the REPL with more than 8 elements should create a PHM backed set but instead it is array backed.

Example (in REPL):
cljs.user=> (type (.-hash-map #{1 2 3 4 5 6 7 8 9}))
cljs.core/PersistentArrayMap

This means operations such as `get` and `contains?` end up doing long scans and are slower than a user would expect.






[CLJS-1763] Defining a var that clashes with `cljs.core` throws a compiler error instead of warning Created: 24/Aug/16  Updated: 24/Aug/16  Resolved: 24/Aug/16

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

Type: Defect Priority: Major
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1763.patch    
Patch: Code and Test

 Comments   
Comment by António Nuno Monteiro [ 24/Aug/16 10:43 AM ]

Attached patch with fix and test.

Comment by David Nolen [ 24/Aug/16 11:40 AM ]

fixed https://github.com/clojure/clojurescript/commit/7a06d008fadf56b11dba0f9e2ab97e61059f44fc





[CLJS-1634] Track bound dynamic variables to support binding in async mechanisms. Created: 26/Apr/16  Updated: 20/Aug/16

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: 1.7.228
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Christian Weilbach Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: cljs, enhancement
Environment:

Any cljs version.



 Description   

The issue has been raised before:

While the reasoning behind the proposal is still valid, the original approach has made no progress due to the performance penalty. I have implemented a simplified approach with mutable JavaScript datastructures to minimize the performance impact. Because we are single-threaded we can use js assignment and don't need to port Clojure's binding frame. A small penalty is paid by the user of binding (see benchmark8) and a higher one by async mechanisms capturing and restoring the bindings (benchmark1-7):

https://gist.github.com/whilo/a8ef2cd3f0e033d3973880a2001be32a

I would provide patches to ClojureScript, if this looks like a worthwhile approach.



 Comments   
Comment by Antonin Hildebrand [ 30/Apr/16 6:05 AM ]

Just for record I commented on it here: https://gist.github.com/whilo/a8ef2cd3f0e033d3973880a2001be32a#gistcomment-1764489. Not sure if GitHub sends out notifications about new gist comments.

Comment by Christian Weilbach [ 30/Apr/16 6:18 AM ]

Thanks for pointing it out. David Nolen has also pointed out prototype chains to address this issue and now I see what he meant. I am not familiar enough with the internals of "this" in JavaScript, but one problem I see is that you need to distinguish dynamic vars at the call site. The advantage of using an object directly and capturing and restoring the frame explicitly when you enter and leave the code is that call sites are totally unaffected. The cost is only paid a little at the binding site and mostly in async libraries (bound-fn). But I might still need to look further into "this" . I have not got the gist comment from github.

Comment by Antonin Hildebrand [ 30/Apr/16 7:23 AM ]

Correct.

> you need to distinguish dynamic vars at the call site

I agree. My initial motivation was to solve a bit different problem without cooperation from library authors. I didn't want to modify ClojureScript behaviour and wanted to be just touching own code or doing trivial changes in library forks. Just wanted to share my thoughts about the implementation.

I have a feeling that solving this "async context" problem will be difficult. You will need async library authors to adapt their libraries. And users unaware of this will be running into issues anytime they step outside of bound-fn aware async libraries (for example using raw js interop). I believe Angular people solved this robustly in https://github.com/angular/zone.js. The implementation is quite scary monkey-patching, but if they were able to wrap all existing async calls at lowest level, maybe we could just build on top of their foundation and use zone.js as parallel mechanism for `binding`.

Comment by Christian Weilbach [ 02/May/16 4:58 PM ]

The angle I am coming from is roughly described here: https://github.com/fullcontact/full.monty/pull/9#issuecomment-131152058

I only found out at the very end when I had supervision of go-channels completely implemented, that the cljs binding was not behaving like the Clojure one. Arguments pro/contra binding in Clojure are also referenced. The zone monkey patching looks very heavy and prone to cause hairy bugs. It is noteworthy that Clojure does not embrace bindings, but keeps them always thread-local. So there you also have to use bound-fn or something similar whenever code is executed concurrently. core.async for instance uses the Clojure mechanism to push (capture) and pop (restore) bindings. I would like to have this in ClojureScript as well. I think one should not retain all bindings automatically, but rather allow the library author to handle dynamic bindings. I only track the supervisor binding for instance. For ClojureScript as for Clojure libraries and wrappers this should be fine. Pure JavaScript libraries usually have their own binding concepts like zone.js, right?

Tracking bindings is neither for free in Clojure nor in ClojureScript and it is an important design goal to embrace the host. In fact originally I tried to capture and restore all bindings. My benchmarks for tracking more dynamic vars (instead of just the currently active binding), were linearly more expansive than rebinding fewer selected vars and become prohibitive when you reach a few hundred.

Comment by Antonin Hildebrand [ 02/May/16 5:16 PM ]

I would be happy if your proposal went through. It would help my use-cases as well.

I'm going to explore zone.js when I get some spare time. I will try do write a wrapper library and implement an alternative mechanism to bindings using zone.js. I would like to provide this functionality as a library without a need to modify ClojureScript compiler or involvement from library authors.

Comment by Christian Weilbach [ 03/May/16 1:39 AM ]

Ok, I am curious how well this will work. Would this work with the state-machine transformation of core.async?

Comment by Antonin Hildebrand [ 03/May/16 3:25 AM ]

I believe so. Core.async state machine uses only setTimeout and goog.async.nextTick. We can teach zone.js to deal with nextTick by setting goog.async.nextTick.wrapCallback_ with zone wrapping. Also if user decided to use any async API in their go blocks it should work, because zone.js will carry proper zone binding over async boundaries.

Comment by Antonin Hildebrand [ 03/May/16 3:50 AM ]

I have opened this issue in zone.js: https://github.com/angular/zone.js/issues/342

Comment by Christian Weilbach [ 26/May/16 8:56 AM ]

Hey. Have you made any progress with implementing a small cljs demo with zone.js yet?

Comment by Antonin Hildebrand [ 27/May/16 5:57 AM ]

Hi Christian. No, unfortunately I didn't get to it.

Comment by Christian Weilbach [ 07/Aug/16 4:26 PM ]

Interestingly to implement the Common Lisp like condition system chouser presented here https://www.youtube.com/watch?v=zp0OEDcAro0 the dynamic binding working over async boundaries is also important.

Comment by Antonin Hildebrand [ 08/Aug/16 5:53 PM ]

Christian, please have a look at my implementation:
https://github.com/binaryage/cljs-zones

I have implemented the prototype trick as a library. It is just a gist of the idea, didn't spend time to make it robust yet and ES3-compatible. Re-binding frames should be as cheap as changing pointers (inside JS runtime).

Comment by Christian Weilbach [ 10/Aug/16 6:10 AM ]

Very nice work! I am checking it out atm. Nice that it is self-contained. (The Klipse version throws a goog.object not found error for me btw.)

Comment by Christian Weilbach [ 16/Aug/16 4:05 PM ]

I have updated the gist to incorporate cljs-zones in benchmark 8, 9 and 10. It is a bit faster in restoring dynamic bindings, but not much:

https://gist.github.com/whilo/a8ef2cd3f0e033d3973880a2001be32a

But there is a significant performance penalty on var access:

full.binding_test.benchmark10()
core.cljs:150 [], ((fn [] v1)), 10000 runs, 1 msecs
core.cljs:150 [], ((fn [] (zones/get v1))), 10000 runs, 4 msecs
null
full.binding_test.benchmark10()
core.cljs:150 [], ((fn [] v1)), 10000 runs, 2 msecs
core.cljs:150 [], ((fn [] (zones/get v1))), 10000 runs, 6 msecs
null
full.binding_test.benchmark10()
core.cljs:150 [], ((fn [] v1)), 10000 runs, 3 msecs
core.cljs:150 [], ((fn [] (zones/get v1))), 10000 runs, 4 msecs

Is this penalty addressable?

One other issue is that JavaScript prototype manipulations through "this" would interfere with the cljs binding mechanism, but this might be acceptable.

Comment by Antonin Hildebrand [ 16/Aug/16 4:17 PM ]

Thanks for measuring it. I didn't really get to benchmarking yet.

Did you run the benchmarks under :advanced optimizations?

zones/get currently emits a call to goog.object/get, I'm not sure if this gets inlined by closure compiler, but if not, we can probably improve it by generating raw js object access:
https://github.com/binaryage/cljs-zones/blob/fdfa1421c39d64c9c6b9efbff474b7677f908197/src/lib/zones/core.clj#L94

> One other issue is that JavaScript prototype manipulations through "this" would interfere with the cljs binding mechanism
Can you elaborate? I don't understand how it would interfere.

Comment by Christian Weilbach [ 17/Aug/16 4:10 AM ]

With advanced compilation I get:

full.binding_test.benchmark10()
client.js:278 [], ((fn [] v1)), 10000 runs, 1 msecs
client.js:278 [], ((fn [] (zones/get v1))), 10000 runs, 2 msecs
null
full.binding_test.benchmark10()
client.js:278 [], ((fn [] v1)), 10000 runs, 2 msecs
client.js:278 [], ((fn [] (zones/get v1))), 10000 runs, 3 msecs
null
full.binding_test.benchmark10()
client.js:278 [], ((fn [] v1)), 10000 runs, 3 msecs
client.js:278 [], ((fn [] (zones/get v1))), 10000 runs, 2 msecs
null
full.binding_test.benchmark10()
client.js:278 [], ((fn [] v1)), 10000 runs, 1 msecs
client.js:278 [], ((fn [] (zones/get v1))), 10000 runs, 2 msecs
null
full.binding_test.benchmark10()
client.js:278 [], ((fn [] v1)), 10000 runs, 1 msecs
client.js:278 [], ((fn [] (zones/get v1))), 10000 runs, 3 msecs
null
full.binding_test.benchmark10()
client.js:278 [], ((fn [] v1)), 10000 runs, 1 msecs
client.js:278 [], ((fn [] (zones/get v1))), 10000 runs, 1 msecs

But this is a very simple test. If you see a better way to benchmark it, go ahead . When the chains get prototype chains get longer, it might be more painful to walk the chain for each global lookup.

> Can you elaborate? I don't understand how it would interfere.
There has been a proposal somewhere to pass "this" in all cljs functions instead of null as first argument. Your explicit model of a zone is pretty safe I think, but if people would interefere with prototypes in JS, then this might break the "this" approach in subtle ways. Without passing "this" as a direct argument and doing it in a more JS way, you have to setup the zones all the time instead of using the scope chain, which might also contribute to the managing cost. So the "this" approach might help with performance, but I am not sure. You still have the chain overhead. But I am no JS expert, you know much better than me what you are doing.

Comment by Christian Weilbach [ 20/Aug/16 5:37 AM ]

My last comment was a little bit confusing. I only see the problem with an impact on dereferencing vars. In the benchmark above the prototype chain is very short (v1 can be directly resolved) and already has a significant penalty, but I think the penalty gets even worse for not rebound root vars if you have a higher nesting level for the binding and the chain gets longer. Can you address this somehow?





[CLJS-1759] Errors writing transit analysis cache if parallel build Created: 19/Aug/16  Updated: 19/Aug/16  Resolved: 19/Aug/16

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

Type: Defect Priority: Major
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1759.patch    
Patch: Code

 Description   
  1. It fails only if parallel builds enabled
  2. When so, it fails, maybe 30 to 50% of the time
  3. If I put a coarse-grained mutex around the write calls, it succeeds
  4. It appears to occur under heave write load 3 concurrent writes

Here is an example of one of the failures:

Exception in thread "main" clojure.lang.ExceptionInfo: failed compiling file:out/cljs/source_map/base64.cljs {:file #object[java.io.File 0x125a8ab6 "out/cljs/source_map/base64.cljs"]}, compiling:(/Users/mfikes/Projects/planck/planck-cljs/script/build.clj:16:1)
        at clojure.lang.Compiler.load(Compiler.java:7391)
        at clojure.lang.Compiler.loadFile(Compiler.java:7317)
        at clojure.main$load_script.invokeStatic(main.clj:275)
        at clojure.main$script_opt.invokeStatic(main.clj:335)
        at clojure.main$script_opt.invoke(main.clj:330)
        at clojure.main$main.invokeStatic(main.clj:421)
        at clojure.main$main.doInvoke(main.clj:384)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.lang.Var.invoke(Var.java:379)
        at clojure.lang.AFn.applyToHelper(AFn.java:154)
        at clojure.lang.Var.applyTo(Var.java:700)
        at clojure.main.main(main.java:37)
Caused by: clojure.lang.ExceptionInfo: failed compiling file:out/cljs/source_map/base64.cljs {:file #object[java.io.File 0x125a8ab6 "out/cljs/source_map/base64.cljs"]}
        at clojure.core$ex_info.invokeStatic(core.clj:4617)
        at clojure.core$ex_info.invoke(core.clj:4617)
        at cljs.compiler$compile_file$fn__3456.invoke(compiler.cljc:1386)
        at cljs.compiler$compile_file.invokeStatic(compiler.cljc:1352)
        at cljs.compiler$compile_file.invoke(compiler.cljc:1332)
        at cljs.closure$compile_file.invokeStatic(closure.clj:474)
        at cljs.closure$compile_file.invoke(closure.clj:465)
        at cljs.closure$eval5203$fn__5204.invoke(closure.clj:541)
        at cljs.closure$eval5139$fn__5140$G__5128__5147.invoke(closure.clj:431)
        at cljs.closure$compile_from_jar.invokeStatic(closure.clj:523)
        at cljs.closure$compile_from_jar.invoke(closure.clj:511)
        at cljs.closure$eval5209$fn__5210.invoke(closure.clj:551)
        at cljs.closure$eval5139$fn__5140$G__5128__5147.invoke(closure.clj:431)
        at cljs.closure$compile_task$fn__5294.invoke(closure.clj:821)
        at cljs.closure$compile_task.invokeStatic(closure.clj:819)
        at cljs.closure$compile_task.invoke(closure.clj:812)
        at cljs.closure$parallel_compile_sources$fn__5300.invoke(closure.clj:848)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.AFn.applyTo(AFn.java:144)
        at clojure.core$apply.invokeStatic(core.clj:646)
        at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1881)
        at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1881)
        at clojure.lang.RestFn.invoke(RestFn.java:425)
        at clojure.lang.AFn.applyToHelper(AFn.java:156)
        at clojure.lang.RestFn.applyTo(RestFn.java:132)
        at clojure.core$apply.invokeStatic(core.clj:650)
        at clojure.core$bound_fn_STAR_$fn__4671.doInvoke(core.clj:1911)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at clojure.lang.AFn.run(AFn.java:22)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: java.lang.Exception: Not supported: class java.lang.Integer
        at com.cognitect.transit.impl.WriterFactory$1.write(WriterFactory.java:129)
        at cognitect.transit$write.invokeStatic(transit.clj:149)
        at cognitect.transit$write.invoke(transit.clj:146)
        at cljs.analyzer$write_analysis_cache.invokeStatic(analyzer.cljc:3127)
        at cljs.analyzer$write_analysis_cache.invoke(analyzer.cljc:3114)
        at cljs.compiler$emit_source.invokeStatic(compiler.cljc:1283)
        at cljs.compiler$emit_source.invoke(compiler.cljc:1232)
        at cljs.compiler$compile_file_STAR_$fn__3433.invoke(compiler.cljc:1304)
        at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1154)
        at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1145)
        at cljs.compiler$compile_file_STAR_.invokeStatic(compiler.cljc:1293)
        at cljs.compiler$compile_file_STAR_.invoke(compiler.cljc:1289)
        at cljs.compiler$compile_file$fn__3456.invoke(compiler.cljc:1374)
        ... 29 more


 Comments   
Comment by Mike Fikes [ 19/Aug/16 9:48 AM ]

The attached patch introduces a coarse-grained mutex as indicated in item (3) of the description, providing a work-around for the issue.

Comment by Mike Fikes [ 19/Aug/16 10:43 AM ]

A follow up enhancement ticket that would potentially lead to removing the (presumed) workaround in the patch: CLJS-1761

Comment by David Nolen [ 19/Aug/16 10:44 AM ]

fixed https://github.com/clojure/clojurescript/commit/002708e530b6b3449151d3d077883beeadb92f94





[CLJS-1760] Self-host: test-cljs-1757 failing in test-self-parity Created: 19/Aug/16  Updated: 19/Aug/16  Resolved: 19/Aug/16

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

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bootstrap, spec

Attachments: Text File CLJS-1760.patch    
Patch: Code

 Description   
$ script/test-self-parity
Testing with Node
WARNING: baz is a single segment namespace at line 1
WARNING: Use of undeclared Var cljs.spec$macros/gen at line 77

Testing cljs.core-test

Testing cljs.reader-test

Testing clojure.string-test

Testing clojure.data-test

Testing cljs.letfn-test

Testing cljs.reducers-test

Testing cljs.binding-test

Testing cljs.macro-test

Testing cljs.top-level

Testing cljs.ns-test.foo

Testing foo.ns-shadow-test

Testing cljs.import-test

Testing cljs.spec-test

ERROR in (test-cljs-1757) (TypeError:NaN:NaN)
expected: (s/exercise-fn (quote cljs.spec-test/cljs-1757-x))
  actual: #object[TypeError TypeError: Cannot read property 'call' of undefined]

Testing cljs.clojure-alias-test

Ran 215 tests containing 17428 assertions.
0 failures, 1 errors.


 Comments   
Comment by António Nuno Monteiro [ 19/Aug/16 10:25 AM ]

Attached path with fix.

Comment by Mike Fikes [ 19/Aug/16 10:39 AM ]

LGTM. It is the “correct” fix; I missed when putting together CLJS-1720. All tests pass for me with António's patch.

Comment by David Nolen [ 19/Aug/16 10:42 AM ]

fixed https://github.com/clojure/clojurescript/commit/86a83d720beb44deb5d55d7d9c0bc2d5174816a3





[CLJS-1751] port fix lost type hints in map destructuring Created: 15/Aug/16  Updated: 18/Aug/16  Resolved: 18/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1751.patch    
Patch: Code

 Comments   
Comment by António Nuno Monteiro [ 15/Aug/16 3:24 PM ]

Attached patch with fix.

Comment by David Nolen [ 18/Aug/16 4:08 PM ]

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





[CLJS-1758] QuickStart guide fails at browser REPL step with "TypeError: parentElm is null" Created: 18/Aug/16  Updated: 18/Aug/16  Resolved: 18/Aug/16

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

Type: Defect Priority: Minor
Reporter: Tim McCormack Assignee: Unassigned
Resolution: Not Reproducible Votes: 0
Labels: None


 Description   

When I follow http://clojurescript.org/guides/quick-start up to the browser REPL step, I get an error in the browser console and the REPL never connects. The browser error is TypeError: parentElm is null on line 482 of crosspagechannel.js: parentElm.appendChild(iframeElm);.

I have put up a self-contained example to demonstrate the bug: https://github.com/timmc/sscce-CLJS-1758

  • I am using this command to run the REPL: rlwrap java -cp cljs-1.9.216.jar:src clojure.main repl.clj
  • Refreshing the browser does not help.
  • Using Chromium 52.0.2743.116 instead of Firefox ESR 45.3.0 does not help.
$ java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

$ uname -a
Linux bc-timmc 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02) x86_64 GNU/Linux
(Debian GNU/Linux 8.5)


 Comments   
Comment by Tim McCormack [ 18/Aug/16 11:27 AM ]

CLJS 1.9.89 fails the same way.

Comment by António Nuno Monteiro [ 18/Aug/16 11:51 AM ]

Not a bug. Your index.html file needs to at least have a `<body>` tag.
All html examples in the quickstart provide valid HTML, you just chose not to use it.

Comment by Tim McCormack [ 18/Aug/16 12:41 PM ]

Ah, of course! I compared the other files with the demo, but not that one!

I could have sworn the body element was always created automatically in the DOM whether or not it was declared. TIL.

(And confirmed, it works now.)

ETA: Not sure which resolution to pick, so leaving open.





[CLJS-1756] Add test.check JAR to the bootstrap script Created: 17/Aug/16  Updated: 18/Aug/16  Resolved: 18/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1756.patch    
Patch: Code

 Comments   
Comment by António Nuno Monteiro [ 17/Aug/16 10:03 AM ]

Added patch with fix.

Comment by David Nolen [ 18/Aug/16 3:59 PM ]

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





[CLJS-1757] cljs.spec/exercise-fn doesn't work when passed a quoted symbol Created: 17/Aug/16  Updated: 17/Aug/16  Resolved: 17/Aug/16

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

Type: Defect Priority: Major
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: spec

Attachments: Text File CLJS-1757.patch    
Patch: Code and Test

 Description   
cljs.user=> (require '[clojure.spec :as s])
nil
cljs.user=> (defn a [b] 2)
#'cljs.user/a
cljs.user=> (s/fdef a :args (s/cat ::first number?) :ret #(= % 2))
cljs.user/a
cljs.user=> (s/exercise-fn `a)
clojure.lang.ExceptionInfo: Assert failed: (symbol? sym) at line 1 <cljs repl> {:file "<cljs repl>", :line 1, :column 1, :root-source-info {:source-type :fragment, :source-form (s/exercise-fn (quote cljs.user/a))}, :tag :cljs/analysis-error}


 Comments   
Comment by António Nuno Monteiro [ 17/Aug/16 12:31 PM ]

Attached patch with fix and test.

Comment by David Nolen [ 17/Aug/16 7:32 PM ]

fixed https://github.com/clojure/clojurescript/commit/74db88011dd6dd64f55521f074f0315231be0e12





[CLJS-1754] Add boolean? generator Created: 16/Aug/16  Updated: 17/Aug/16  Resolved: 17/Aug/16

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

Type: Defect Priority: Major
Reporter: Matt Burbidge Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: cljs, spec

Attachments: Text File CLJS-1754.patch    
Patch: Code and Test

 Description   

In clojure I can do
`(gen/generate (s/gen int?)) ;; => 1094`
or
`(gen/generate (s/gen boolean?)) ;; => false`.

In clojurescript I can do
`(gen/generate (s/gen int?)) ;; => -308`.
But in clojurescript I can't do
`(gen/generate (s/gen boolean?)) ;; => Error: Unable to construct gen at: [] for: function cljs$core$boolean_QMARK_{return (x === true) || (x === false);}].`

As far as I can tell it's because there is no boolean generator.



 Comments   
Comment by António Nuno Monteiro [ 17/Aug/16 10:04 AM ]

Added patch with fix and test.

Note that running self parity tests now depends on CLJS-1756 being in place.

Comment by David Nolen [ 17/Aug/16 10:40 AM ]

fixed https://github.com/clojure/clojurescript/commit/2a7454837244cf7de3dfed1e48f46f86c33a1809





[CLJS-1755] Support sourcesContent in source maps Created: 16/Aug/16  Updated: 16/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: Daniel Compton Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: sourcemap


 Description   

This issue adds sourcesContent support for source maps: https://github.com/google/closure-compiler/issues/1890. This means that your source maps can include your source as well in one bundled file. This makes handling sourcemaps much easier for things like error tracking services. It could also simplify config for source mapping as everything is included in the source map and you don't need to specify relative paths, e.t.c.

This will need to wait for the next release of the Closure Compiler.






[CLJS-1346] Support require outside of ns Created: 18/Jul/15  Updated: 16/Aug/16

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

Type: Enhancement Priority: Major
Reporter: Jonathan Boston Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None


 Description   

Makes http://dev.clojure.org/jira/browse/CLJS-1277 useful.



 Comments   
Comment by António Nuno Monteiro [ 16/Aug/16 3:40 PM ]

My initial thoughts to tackle this one would be:

  • add support for the `require` special form (along with `require-macros`, `use`, `use-macros`, `refer-clojure` and `import` for completeness) in the analyzer.
  • have `cljs.analyzer/parse-ns` recognize more than the `:ns` AST :op, merging `require`s/`uses` etc into NS requires. Use the 'cljs.user NS by default if no NS form found.
  • this means that `cljs.closure/find-cljs-dependencies` can get at the `require`d dependencies in the build pipeline.

Pending questions:

  • How to disallow `require` etc. except at the top level?
  • Possibly only even allow it strictly after the NS form, or one or the other?




[CLJS-1752] stest/instrument never throws or :ret and :fn Created: 16/Aug/16  Updated: 16/Aug/16  Resolved: 16/Aug/16

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

Type: Defect Priority: Minor
Reporter: Jan Hein Hoogstad Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: cljs, spec


 Description   

When I replace the spec for the following function:

(defn create [query]
  (with-meta (map->Query query) {:spec ::specs/query}))

from:

(spec/fdef create
           :args (spec/cat :query ::specs/query)
           :ret ::specs/query
           :fn #(spec/valid? ::specs/meta (-> %1 :ret :meta)))

(stest/instrument `create)

to

(spec/fdef create
           :args (spec/cat :query ::specs/query)
           :ret string?
           :fn #(spec/valid? ::specs/meta (-> %1 :ret :meta)))

(stest/instrument `create)

it does not throw. As a matter of fact, I didn't get it to throw on any value that I give the :ret and :fn function. Removing the record with a plain map did not make a difference...



 Comments   
Comment by David Nolen [ 16/Aug/16 10:24 AM ]

This is by design.

Comment by Jan Hein Hoogstad [ 16/Aug/16 10:34 AM ]

Thanks for the quick reply, but it is not clear to me why? Can you maybe point me to an explanation?

Cheer!

Comment by Jan Hein Hoogstad [ 16/Aug/16 11:06 AM ]

Never mind, found it. Hadn't noticed it before...





[CLJS-1753] cljs.pprint does not print default tagged literals/elements Created: 16/Aug/16  Updated: 16/Aug/16

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

Type: Defect Priority: Major
Reporter: Miroslav Kubicek Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: bug
Environment:

Win 7 64bit



 Description   

Hi there!
I am having troubles making the cljs pretty print (cljs.pprint/pprint) behave the same way as the regular cljs or clj print function when it goes down to tagged elements that are by default used to denote custom records.

See example below - pr, pr-str, print and print-str functions all use the default approach toward creating (edn-like) tagged element for MyRecord and all produce the same result:
#cljs.user.MyRecord{:value "a"}

On the other hand pprint just ignores the record's tag and simply just traverses/prints it as a map:
{:value "a"}

Is there some setting and/or parameter in cljs.pprint namespace I am missing? I looked briefly at the code, but it seems it uses print-str by default - so maybe it just traverses the graph depth-first and does not check for every node's type? At this stage this seems like a bug to me as the expected behavior of the pprint function is that it would behave the same way print and other core functions do.

THIS WORKS:

cljs.user=> (defrecord MyRecord [value])
cljs.user/MyRecord
cljs.user=> (pr (MyRecord. "a"))
#cljs.user.MyRecord{:value "a"}
nil
cljs.user=> (pr-str (MyRecord. "a"))
"#cljs.user.MyRecord{:value \"a\"}"
cljs.user=> (print (MyRecord. "a"))
#cljs.user.MyRecord{:value a}
nil
cljs.user=> (print-str (MyRecord. "a"))
"#cljs.user.MyRecord{:value a}"

BUT THIS DOESN'T:

cljs.user=> (cljs.pprint/pprint (MyRecord. "a"))
{:value "a"}
("{:value \"a\"}\n")
cljs.user=> (with-out-str (cljs.pprint/pprint (MyRecord. "a")))
"{:value \"a\"}\n"

According to github the head revision of the cljs.pprint namespace has not changed since 1.7.28 so I'd assume all versions up to the current one are affected.

Thanks for help!






[CLJS-1749] Missing `cljs.spec.impl.gen/double*` Created: 15/Aug/16  Updated: 15/Aug/16  Resolved: 15/Aug/16

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

Type: Defect Priority: Minor
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1749.patch    
Patch: Code

 Comments   
Comment by António Nuno Monteiro [ 15/Aug/16 12:05 PM ]

Attached patch with fix.

Comment by David Nolen [ 15/Aug/16 12:53 PM ]

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





[CLJS-1747] Port `clojure.spec/assert` over to ClojureScript Created: 15/Aug/16  Updated: 15/Aug/16  Resolved: 15/Aug/16

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

Type: Defect Priority: Major
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1747.patch    
Patch: Code and Test

 Comments   
Comment by António Nuno Monteiro [ 15/Aug/16 11:28 AM ]

Attached patch with fix and test.

Comment by David Nolen [ 15/Aug/16 12:52 PM ]

fixed https://github.com/clojure/clojurescript/commit/862950da92581b60abc3bc615305461a7e1c1bfb





[CLJS-1746] Log the result of loading a dependency Created: 14/Aug/16  Updated: 15/Aug/16  Resolved: 15/Aug/16

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

Type: Enhancement Priority: Trivial
Reporter: Andrea Richiardi Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1746.patch    

 Description   

It would be great to add a (debug-prn "Loading result: " res) in load-deps so that we see in the logs why a dependency failed to load.
It is a one line patch and I can take care of it.



 Comments   
Comment by Andrea Richiardi [ 14/Aug/16 9:16 PM ]

Patch attached

Comment by David Nolen [ 15/Aug/16 7:41 AM ]

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





[CLJS-1657] Self-host: Implicit macro loading with alias Created: 01/Jun/16  Updated: 14/Aug/16  Resolved: 14/Aug/16

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

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 1
Labels: bootstrap

Attachments: Text File CLJS-1657.patch    
Patch: Code and Test

 Description   

If a namespace relies on implicit macro loading (described here https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure#namespaces), and an alias is used, it is possible for aliased symbol resolution to fail.

This can be reproduced by adding a 10th case in self-host.test/test-load-and-invoke-macros covering this situation:

(let [st (cljs/empty-state)]
        ;; Rely on implicit macro loading (ns loads its own macros), with an alias
        (cljs/eval-str st
          "(ns cljs.user (:require [foo.core :as foo]))"
          nil
          {:eval node-eval
           :load (fn [{:keys [macros]} cb]
                   (if macros
                     (cb {:lang :clj :source "(ns foo.core) (defmacro add [a b] `(+ ~a ~b))"})
                     (cb {:lang :clj :source "(ns foo.core (:require-macros foo.core))"})))}
          (fn [{:keys [value error]}]
            (is (nil? error))
            (cljs/eval-str st
              "(foo/add 300 500)"
              nil
              {:eval    node-eval
               :context :expr}
              (fn [{:keys [error value]}]
                (is (nil? error))
                (is (= 800 value))
                (inc! l))))))

This will result in:

Testing self-host.test

FAIL in (test-load-and-invoke-macros) (at .../clojurescript/builds/out-self/core-self-test.js:11545:454)
expected: (nil? error)
  actual: (not (nil? #error {:message "ERROR", :data {:tag :cljs/analysis-error}, :cause #object[TypeError TypeError: Cannot read property 'call' of undefined]}))

FAIL in (test-load-and-invoke-macros) (at .../clojurescript/builds/out-self/core-self-test.js:11548:49)
expected: (= 800 value)
  actual: (not (= 800 nil))


 Comments   
Comment by Mike Fikes [ 01/Jun/16 7:48 AM ]

Analysis: This is because, this bit of code https://github.com/clojure/clojurescript/blob/19510523ad9de3f16832d287bae86f701e8b4263/src/main/clojure/cljs/analyzer.cljc#L1817-L1820
has a branch that only works in non-bootstrap ClojureScript.

You can also work around the issue (or gain a better understanding) in several ways (if you can control the affected loading namespace—this won't work if this affects code down in a library you are loading):

1. You can add :include-macros true
2. You can load the self-macro-loading namespace twice. (For example, if at the REPL, you can (require [foo.core :as foo]) twice.) This causes the analysis state to be set up so that on the second require, it is taken care of in the first clause of the or in the linked code above.
3. You can even assoc-in enough state prior to the load so that you are effectively doing (2).

In all of these cases, when it fails, vs. when it succeeds, you can see a difference in the :require-macros key in the analysis map of the loading namespace ('cljs.user, for example). When it fails, you will see that this key is empty and when it succeeds, you will see that the key is populated, and in particular, with the foo alias.

In the case where you don't use an alias, implicit macro loading will fail in a way that won't be visible: The :require-macros key will not be set up as described above, but qualified symbol resolution will still succeed (foo.core/add in the example will resolve to foo.core$macros/add), probably simply owing to the way resolution is performed.

Comment by Mike Fikes [ 14/Aug/16 1:48 PM ]

As António Monteiro points out, this is no longer reproducible. My recommendation would be to add the additional unit test in the description and to also remove the workaround on this line

https://github.com/clojure/clojurescript/blob/756fa9bb196a97e0ae40fd644da5e492e0336c1c/src/test/self/self_parity/test.cljs#L233-L237

(and the two calls to it below), and ultimately with a patch to lock down these unit tests, resolve this as fixed.

Comment by António Nuno Monteiro [ 14/Aug/16 5:22 PM ]

As per Mike Fikes's feedback, attached a patch that adds the proposed unit test and removes the workaround for the issue from self parity tests.

Comment by David Nolen [ 14/Aug/16 7:05 PM ]

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





[CLJS-1544] cljs.test REPL reload support Created: 13/Jan/16  Updated: 14/Aug/16

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

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


 Description   

When adding a test to a test ns that uses cljs.test and re-loading (via require + :reload) that namespace in the REPL after saving the file - invoking run-tests does not include the newly added test.






[CLJS-1742] Add docstring for new refer-clojure REPL special Created: 12/Aug/16  Updated: 14/Aug/16  Resolved: 14/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: docstring

Attachments: Text File CLJS-1742-2.patch     Text File CLJS-1742.patch    
Patch: Code

 Description   

Add a docstring for the new REPL special refer-clojure introduced with CLJS-1730.



 Comments   
Comment by António Nuno Monteiro [ 14/Aug/16 1:58 PM ]

Attached patch with fix.

Comment by António Nuno Monteiro [ 14/Aug/16 2:09 PM ]

Attached revised CLJS-1742-2.patch which drops reference to `inclusion` (used with Clojure's `:only` filter, not supported in ClojureScript)

Comment by David Nolen [ 14/Aug/16 2:36 PM ]

fixed https://github.com/clojure/clojurescript/commit/63e0d7380ee5c45d74a93613aafe982ee600e990





[CLJS-1745] refer-clojure doesn't pull in previously excluded vars Created: 14/Aug/16  Updated: 14/Aug/16

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

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


 Description   

Observe this behavior in Clojure:

user=> (ns foo.core (:refer-clojure :exclude [juxt partial]))
nil
foo.core=> juxt
CompilerException java.lang.RuntimeException: Unable to resolve symbol: juxt in this context, compiling:(NO_SOURCE_PATH:0:0)
foo.core=> partial
CompilerException java.lang.RuntimeException: Unable to resolve symbol: partial in this context, compiling:(NO_SOURCE_PATH:0:0)
foo.core=> (refer-clojure :exclude [])
nil
foo.core=> juxt
#object[clojure.core$juxt 0x2f62ea70 "clojure.core$juxt@2f62ea70"]
foo.core=> partial
#object[clojure.core$partial 0x38aa816f "clojure.core$partial@38aa816f"]

Compare with ClojureScript:

$ script/noderepljs
ClojureScript Node.js REPL server listening on 49402
To quit, type: :cljs/quit
cljs.user=> (ns foo.core (:refer-clojure :exclude [juxt partial]))
nil
foo.core=> juxt
nil
foo.core=> partial
nil
foo.core=> (refer-clojure :exclude [])
nil
foo.core=> juxt
nil
foo.core=> partial
nil





[CLJS-1623] using `with-redefs` to add meta to a function via `with-meta` fails when using advanced compilation Created: 12/Apr/16  Updated: 14/Aug/16  Resolved: 14/Aug/16

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

Type: Defect Priority: Minor
Reporter: Justin Cowperthwaite Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

Given the following:

(ns test.cljs)

(enable-console-print!)

(defn print-foobar [] (println "foobar"))

(defn test-redefs-meta []
  (print-foobar)
  (with-redefs [print-foobar (with-meta print-foobar {:foo "bar"})]
    (print-foobar)))

(test-reefs-meta)

running with `:optimizations :none`, it correctly prints:

foobar
footer

However, running with `:optimizations :advanced`, it prints:

foobar
main.js:232 Uncaught TypeError: te is not a function(anonymous function) @ main.js:232

Reproduced on r1.8.40 and current master (29eb8e0).



 Comments   
Comment by Justin Cowperthwaite [ 14/Apr/16 5:42 PM ]

it seems that the actual issue is with having :static-fns true (as is default under :optimizations :advanced)

Comment by David Nolen [ 06/May/16 2:01 PM ]

This issue needs to provide some hypothesis of what is going wrong.

Comment by António Nuno Monteiro [ 14/Aug/16 12:35 PM ]

I don't think this is a bug. If you want to use `with-redefs` with statics-fns, the var needs to be marked `:dynamic`.

The following revised example works:

(defn ^:dynamic print-foobar [] (println "foobar"))

(defn test-redefs-meta []
  (print-foobar)
  (with-redefs [print-foobar (with-meta print-foobar {:foo "bar"})]
    (print-foobar)))

(test-redefs-meta)
Comment by David Nolen [ 14/Aug/16 1:47 PM ]

No interest in making this work. If you want something to be redefinable with `with-redefs` in production you need to mark those vars ^:dynamic.





[CLJS-1274] Allow assignment to namespace-qualified names in current namespace Created: 17/May/15  Updated: 14/Aug/16  Resolved: 14/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: lvh Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1274-2.patch     Text File CLJS-1274-3.patch     Text File CLJS-1274.patch    
Patch: Code and Test

 Description   

In Clojure, you can def to a namespace-qualified name as long as it's in the current namespace. You can't do that in Clojurescript. This makes writing some macros that def to a local name a bit more annoying, since the syntax-quote will automatically namespace-qualify any symbols, so you have to write the somewhat unsightly and not super obvious ~'sym.



 Comments   
Comment by António Nuno Monteiro [ 14/Aug/16 10:25 AM ]

Attached patch with fix and test.

Comment by António Nuno Monteiro [ 14/Aug/16 11:23 AM ]

Attached a revised patch with a better error message as per Mike Fikes's feedback.

Comment by António Nuno Monteiro [ 14/Aug/16 11:33 AM ]

Patch CLJS-1274-3.patch is the one that should be considered.

Comment by Mike Fikes [ 14/Aug/16 11:47 AM ]

Confirmed that all tests pass for me locally and that this fundamentally works downstream in self-host, emitting a helpful diagnostic related to the pseudo-namespace used for macro namespaces:

cljs.user=> (def cljs.user/bar 3)
#'cljs.user/bar
cljs.user=> bar
3
cljs.user=> (require-macros 'foo.core)
nil
cljs.user=> (source foo.core/deffoo)
(defmacro deffoo [value]
  `(def foo ~value))
nil
cljs.user=> (foo.core/deffoo 5)
            ⬆
Can't def ns-qualified name in namespace foo.core$macros at line 1
Comment by David Nolen [ 14/Aug/16 11:55 AM ]

fixed https://github.com/clojure/clojurescript/commit/756fa9bb196a97e0ae40fd644da5e492e0336c1c





[CLJS-1242] Add cljs.core/pattern? predicate Created: 03/May/15  Updated: 14/Aug/16  Resolved: 14/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: Brandon Bloom Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: patch

Attachments: Text File CLJS-1242_v01.patch    
Patch: Code and Test

 Description   

Just like http://dev.clojure.org/jira/browse/CLJS-1241 , this helps with clj/cljs cross-platform development.



 Comments   
Comment by Brandon Bloom [ 03/May/15 2:38 PM ]

See also http://dev.clojure.org/jira/browse/CLJ-1720

Comment by Brandon Bloom [ 10/May/15 11:36 PM ]

Note that there already is a cljs.core/regexp?, since it's used in a few places by core.

Comment by Samuel Miller [ 27/Jul/15 9:27 PM ]

The patch needs to be updated because of the folder changes

Tested on Linux with V8, SpiderMonkey, and Nashorn. Repljs also functions correctly.

You could have the `pattern?` function point to the `regexp?` function. Maybe there is some reason to keep separate (ability to have non-regex patterns?)

Comment by António Nuno Monteiro [ 14/Aug/16 11:48 AM ]

this would be the same as cljs.core/regexp?

Comment by David Nolen [ 14/Aug/16 11:51 AM ]

Already handled





[CLJS-1029] Investigate how ns aliasing can be supported in ClojureScript macro files Created: 11/Feb/15  Updated: 14/Aug/16  Resolved: 14/Aug/16

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

Type: Task Priority: Minor
Reporter: David Nolen Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

Currently we just require the file. Perhaps possible to control compilation of the macro file such that ClojureScript ns aliases are established. This may not bear fruit but worth thinking about.



 Comments   
Comment by David Nolen [ 11/Feb/15 4:05 PM ]

Any design ideas along this path needs to keep .cljc files in mind.

Comment by David Nolen [ 14/Aug/16 9:07 AM ]

Would introduce a lot of magic for a small payoff.





[CLJS-1744] rest produces nil for larger maps Created: 13/Aug/16  Updated: 14/Aug/16  Resolved: 14/Aug/16

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

Type: Defect Priority: Major
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None


 Description   

CLJS-1739 illustrated an error where rest can produce nil for maps of size 9 or larger.

With code like this

(doseq [i (range 1 20)]
  (prn [i (last (take (inc i) (iterate rest (zipmap (range i) (range i)))))]))

you can demonstrate that while CLJS-1739 addressed it for 9, a similar issue occurs at 17.



 Comments   
Comment by David Nolen [ 13/Aug/16 10:54 PM ]

You mean rest not next, right?

Comment by Mike Fikes [ 13/Aug/16 11:07 PM ]

Yes, the first sentence in the description should have said rest can produce nil.

The doseq above produces output that looks like this (note how it produces nil values starting at 17:

[1 ()]
[2 ()]
[3 ()]
[4 ()]
[5 ()]
[6 ()]
[7 ()]
[8 ()]
[9 ()]
[10 ()]
[11 ()]
[12 ()]
[13 ()]
[14 ()]
[15 ()]
[16 ()]
[17 nil]
[18 nil]
[19 nil]
nil
Comment by David Nolen [ 14/Aug/16 8:25 AM ]

fixed https://github.com/clojure/clojurescript/commit/709cc57d003590945329ea8745b799e75ac4ba88





[CLJS-1743] Transient{Hash,Array}Map should support IFn like in Clojure Created: 13/Aug/16  Updated: 13/Aug/16

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

Type: Enhancement Priority: Trivial
Reporter: Thomas Mulvaney Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File CLJS-1743.patch    
Patch: Code and Test

 Description   

Users should be able to invoke transient maps like in Clojure.






[CLJS-1740] Self-host: Need to port more of CLJS-1733 Created: 12/Aug/16  Updated: 13/Aug/16  Resolved: 13/Aug/16

Status: Resolved
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bootstrap

Attachments: Text File CLJS-1740.patch    
Patch: Code

 Description   

With CLJS-1733 some changes were made that needed to be carried over to self-host.

CLJS-1738 took care of a simple argument refactoring, thus leading to script/test-self-parity passing.

But, script/test-self-host is still failing with failures surrounding unit tests involving the ability to disable analyze deps.

Looking further at the changes made for CLJS-1733, you can see two additional things that need to be ported over:

  1. cljs.js makes a few calls to the cljs.analyzer namespace were cljs.analyzer/analyze-deps is used internally and thus needs to be bound (this fixes script/test-self-host).
  2. With https://github.com/clojure/clojurescript/commit/d197bcb2bef327e00bcb39346258ed314a69b8d9 there is a missing that was previously calculated early in a let and its calculation was moved down to occur later at its use point.


 Comments   
Comment by Mike Fikes [ 12/Aug/16 8:09 PM ]

With the attached patch script/test-self-host goes from failing to passing.

Comment by David Nolen [ 13/Aug/16 10:23 AM ]

fixed https://github.com/clojure/clojurescript/commit/712a8d8f1e69b4f440088ce21d32f63a2e363988





[CLJS-1741] Add :rename to :refer-clojure in ns docstring Created: 12/Aug/16  Updated: 13/Aug/16  Resolved: 13/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: docstring

Attachments: Text File CLJS-1741.patch    
Patch: Code

 Description   

Currently it indicates the only option is :exclude.



 Comments   
Comment by David Nolen [ 13/Aug/16 10:10 AM ]

fixed https://github.com/clojure/clojurescript/commit/0b8fd1271a13ba4f072f85c0f408dd4dfb174bf5





[CLJS-1737] Self-host: clojure alias implicit macro use regression Created: 11/Aug/16  Updated: 13/Aug/16  Resolved: 13/Aug/16

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

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bootstrap

Attachments: Text File CLJS-1737.patch    
Patch: Code and Test

 Description   

If you add a new test case to cljs.clojure-alias-test

(deftest use-macros
  (s/def ::even? (s/and number? even?))
  (is? (s/valid? ::even? 2)))

then script/test-self-parity will fail with

ERROR in (use-macros) (TypeError:NaN:NaN)
Uncaught exception, not in assertion.
expected: nil
  actual: #object[TypeError TypeError: Cannot read property 'call' of undefined]

and issue warnings while failing:

WARNING: Can't take value of macro cljs.spec/def at line 14
WARNING: Can't take value of macro cljs.spec/and at line 14

This appears to be a regression associated with the change made for CLJS-1716. If you check with the previous commit, it will pass. (Note that the proposed unit test needs to be revised slightly to use is instead of is? in order to be applicable to the older code.)



 Comments   
Comment by António Nuno Monteiro [ 13/Aug/16 8:42 AM ]

Attached patch with fix and test.

Comment by Mike Fikes [ 13/Aug/16 9:09 AM ]

I tested this locally and it passes script/test-self-parity. With CLJS-1740 it passes script/test-self-host.

I also tried it downstream with Planck and it works there:

cljs.user=> (require '[clojure.spec :as s])
nil
cljs.user=> (s/def ::even? (s/and number? even?))
:cljs.user/even?
cljs.user=> (s/valid? ::even? 3)
false
cljs.user=> (s/valid? ::even? 4)
true

I also tried the above successfully in script/noderepljs, and I successfully ran script/test (both with and without CLJS-1740).

Comment by David Nolen [ 13/Aug/16 10:07 AM ]

fixed https://github.com/clojure/clojurescript/commit/8a49ce62bb5f53167bc44d75ada31156bcec38b0





[CLJS-1739] seq on map literal with 9 elements leads to rest producing nil Created: 12/Aug/16  Updated: 12/Aug/16  Resolved: 12/Aug/16

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

Type: Defect Priority: Major
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 1
Labels: None


 Description   

Observe that (take 11 (iterate rest {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 :i 9})) produces a nil instead of () right near the end.

({:e 5, :g 7, :c 3, :h 8, :b 2, :d 4, :f 6, :i 9, :a 1} ([:g 7] [:c 3] [:h 8] [:b 2] [:d 4] [:f 6] [:i 9] [:a 1]) ([:c 3] [:h 8] [:b 2] [:d 4] [:f 6] [:i 9] [:a 1]) ([:h 8] [:b 2] [:d 4] [:f 6] [:i 9] [:a 1]) ([:b 2] [:d 4] [:f 6] [:i 9] [:a 1]) ([:d 4] [:f 6] [:i 9] [:a 1]) ([:f 6] [:i 9] [:a 1]) ([:i 9] [:a 1]) ([:a 1]) nil ())


 Comments   
Comment by Rohit Aggarwal [ 12/Aug/16 5:21 PM ]

The following code works as expected:

(take 11 (iterate rest (array-map :a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 :i 9)))
Comment by David Nolen [ 12/Aug/16 6:26 PM ]

fixed https://github.com/clojure/clojurescript/commit/7fe544696ca7dd45785980097f6033f9274e433b





[CLJS-1738] Self-host: need to update call to check-use-macros-inferring-missing Created: 12/Aug/16  Updated: 12/Aug/16  Resolved: 12/Aug/16

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

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bootstrap

Attachments: Text File CLJS-1738.patch    
Patch: Code

 Description   

script/test-self-parity fails owing to a slight simplification in arguments to check-use-macros-inferring-missing. Also, should incorporate call to check-rename-macros-inferring-missing.



 Comments   
Comment by David Nolen [ 12/Aug/16 3:55 PM ]

fixed https://github.com/clojure/clojurescript/commit/5d30d79b9e1fc3394f02de66504b496933458825





[CLJS-1733] Macro inference issue for macros & runtime vars with the same name Created: 11/Aug/16  Updated: 12/Aug/16  Resolved: 12/Aug/16

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

Type: Defect Priority: Minor
Reporter: Thomas Heller Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None


 Description   

The new :rename feature has several cases that are currently not covered and should either throw or warn.

A) :refer-clojure does not account for inline macros.

(ns some.test
  (:refer-clojure :rename {+ plus}))

(plus 1 2) ;; produces cljs.core._PLUS_.cljs$core$IFn$_invoke$arity$2((1),(2));
(cljs.core/+ 1 2) ;; produces ((1) + (2));

The macro version should be used automatically as well.

B) Conflicting :refer and :rename

(:require [clojure.string :refer (blank? starts-with?) :rename {blank? starts-with?}])

The :refer starts-with? is chosen and the rename is ignored. The :rename should either throw or emit a warning.

C) Conflicting :rename

(:require [some.ns :refer (foo bar) :rename {foo baz bar baz}])

Both renames want to use the alias baz. This should warn or throw as well.



 Comments   
Comment by David Nolen [ 12/Aug/16 12:14 PM ]

The problem is not specific to :rename. Even with a normal :require :refer you will see that the only the runtime var will get considered if the name is shared.

Comment by David Nolen [ 12/Aug/16 2:07 PM ]

Solved the typical refer case https://github.com/clojure/clojurescript/commit/b49c19819f46a78e41a1e3c9147b1127a006664d

Comment by David Nolen [ 12/Aug/16 2:27 PM ]

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





[CLJS-1706] cljs.reader support for namespaced map literal Created: 15/Jul/16  Updated: 11/Aug/16

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

Type: Defect Priority: Major
Reporter: Thomas Heller Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None


 Description   

Clojure 1.9 extends support for namespaced maps and cljs.reader needs to be able to read them.

#:example{:key "value"} currently results in a Could not find tag parser for :example in ... error.



 Comments   
Comment by Thomas Heller [ 17/Jul/16 3:20 AM ]

I wanted to start implementing this and started looking at the "spec" [1]. It mentions support for #:: and #::alias, but since cljs.reader does not have access to aliases (or the current ns) I do not know how to proceed. Should it just throw then encountering #:: since it isn't really all that useful in a EDN context?

http://dev.clojure.org/jira/browse/CLJ-1910

Comment by David Nolen [ 10/Aug/16 1:56 PM ]

What does the Clojure EDN reader do here?

Comment by Linus Ericsson [ 11/Aug/16 2:26 PM ]

The clojure.edn-reader seems to catch that it doesn't have a default namespace, nor any aliases.

user> (clojure.edn/read-string "#:a {:b 1}")
{:a/b 1}

user> (clojure.edn/read-string "#::a {:b 1}")
RuntimeException Namespaced map must specify a valid namespace: :a  clojure.lang.EdnReader$NamespaceMapReader.invoke (EdnReader.java:494)

user> (clojure.edn/read-string "#:: {:b 1}")
RuntimeException Invalid token: :  clojure.lang.Util.runtimeException (Util.java:221)

This seems to be sane defaults also for cljs.reader.

Also see the commit adding namespaces maps in clojure





[CLJS-1735] Self-host: cljs.spec speced-vars instance Created: 11/Aug/16  Updated: 11/Aug/16  Resolved: 11/Aug/16

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

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bootstrap

Attachments: Text File CLJS-1735.patch    
Patch: Code

 Description   

Similar to CLJS-1656 but a new instance here: https://github.com/clojure/clojurescript/blob/85bab0736aae442d55d7f25ffc502b5195afe5c1/src/main/cljs/cljs/spec/test.cljc#L105



 Comments   
Comment by David Nolen [ 11/Aug/16 12:32 PM ]

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





[CLJS-1736] cljs.spec.test: checkable-syms* called with 0-arity Created: 11/Aug/16  Updated: 11/Aug/16  Resolved: 11/Aug/16

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

Type: Defect Priority: Major
Reporter: Mike Fikes Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None


 Description   

On this line https://github.com/clojure/clojurescript/blob/85bab0736aae442d55d7f25ffc502b5195afe5c1/src/main/cljs/cljs/spec/test.cljc#L235
checkable-sums* is called with no arguments, but the function is only defined for a single argument arity.



 Comments   
Comment by David Nolen [ 11/Aug/16 12:31 PM ]

fixed https://github.com/clojure/clojurescript/commit/5b34a6d9fab1ff77fe3aee24413ad0783e015e9f





[CLJS-1708] Self-host: [iu]nstrument-1 needs to qualify [iu]nstrument-1* Created: 15/Jul/16  Updated: 11/Aug/16  Resolved: 11/Aug/16

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

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bootstrap

Attachments: Text File CLJS-1708-2.patch     Text File CLJS-1708.patch    
Patch: Code

 Description   

The instrument-1 and unstrument-1 macros refer to instrument-1* and unstrument-1* functions which need to be qualified for bootstrap (otherwise they resolve as being in cljs.spec.test$macros).



 Comments   
Comment by Mike Fikes [ 27/Jul/16 8:36 AM ]

Initial patch no longer applies; attaching revised CLJS-1708-2.patch.

Comment by Mike Fikes [ 10/Aug/16 4:18 PM ]

The updated attached patch is still relevant to master in a bootstrapped context.

Comment by David Nolen [ 11/Aug/16 8:14 AM ]

fixed https://github.com/clojure/clojurescript/commit/85bab0736aae442d55d7f25ffc502b5195afe5c1





[CLJS-1730] Support `refer-clojure` special function in REPLs Created: 10/Aug/16  Updated: 11/Aug/16  Resolved: 11/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1730.patch    
Patch: Code

 Description   

Now that we have support for `:rename` in require specifications, the `refer-clojure` function at the REPL can be a useful addition.



 Comments   
Comment by António Nuno Monteiro [ 10/Aug/16 3:26 PM ]

Attached patch with fix.

Comment by David Nolen [ 11/Aug/16 8:13 AM ]

fixed https://github.com/clojure/clojurescript/commit/39f6d7bae0919fe54e847db2fdcfd621cc6f930d





[CLJS-1707] Self-host: with-instrument-disabled needs to qualify *instrument-enabled* Created: 15/Jul/16  Updated: 11/Aug/16  Resolved: 11/Aug/16

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

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bootstrap

Attachments: Text File CLJS-1707.patch    
Patch: Code

 Description   

The unqualified *instrument-enabled* symbol resolves to cljs.spec.test$macros/*instrument-enabled* in bootstrap. This can be fixed by qualifying the symbol.



 Comments   
Comment by Mike Fikes [ 10/Aug/16 4:26 PM ]

The attached patch is still relevant to master in a bootstrapped context.

Comment by David Nolen [ 11/Aug/16 8:12 AM ]

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





[CLJS-1515] Self-host: Allow :file key in cljs.js/*load-fn* callback Created: 17/Dec/15  Updated: 11/Aug/16  Resolved: 11/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bootstrap

Attachments: Text File CLJS-1515-1.patch     Text File CLJS-1515-2.patch     Text File CLJS-1515-3.patch     Text File CLJS-1515-4.patch     Text File CLJS-1515-5.patch     Text File CLJS-1515-6.patch     Text File CLJS-1515-7.patch    
Patch: Code and Test

 Description   

Bootstrapped ClojureScript is abstracted away from direct I/O by use of a *load-fn* callback. A result is that when a namespace is loaded, the :file attribute associated with def s in [:cljs.analyzer/namespaces 'foo.ns :defs] in the AST is nil, because cljs.analyzer/*cljs-file* cannot be set to a meaningful value.

This ticket asks for an extension to *load-fn*, allowing a :file key to be optionally included by cljs.js clients, and for cljs.analyzer/*cljs-file* to be bound to that value in appropriate places in cljs.js so that the :file info appears in the AST.

One rationale for this :file attribute is that it makes it easier for clients of cljs.js to look up the file for a def, say, for use when implementing a source REPL special, for example.



 Comments   
Comment by Andrea Richiardi [ 17/Dec/15 4:31 PM ]

Initial patch, adding a :file key to load-fn and a :file-env key inside opts and then assigning it to cljs.analyzer/cljs-file in eval-str. This approach can be discussed and we can create an ad-hoc function for binding. It felt right there.
Moreover, cljs.analyzer/cljs-file gets overridden every time with the payload coming from load-fn.
All this was very quickly done in order to have a feedback from who's more expert than me about the consequences. This is also my very first ClojureScript patch

Comment by Mike Fikes [ 17/Dec/15 5:33 PM ]

I tried this patch. It is working fine for me when loading namespaces, but if I use cljs.js/analyze-str where the string is an ns form referring other namespaces loaded via *load-fn*, along with a def, things are off. (I have that ns referring macros from a clj file and a symbol from a cljs file, and the clj file gets associated with the top-level def and the macro, and the def in the referred file ends up with nil.

As a minor aside, the patch has a spurious whitespace change at the end.

Comment by Mike Fikes [ 17/Dec/15 5:56 PM ]

With respect to the last comment: The patch employs the pattern of conveying the :file passed in the cb via a :file-env opt to the consuming fn. It is consumed in eval-str* but not in analyze-str*. If the same logic is added to analyze-str* then the problem mentioned in the last comment goes away.

Comment by David Miller [ 17/Dec/15 6:48 PM ]

I'm hopeful someone will assign this to a responsible party. I am not that person.

Comment by Andrea Richiardi [ 17/Dec/15 7:21 PM ]

sorry David (Miller) and thanks Mike, I will rework it, adding some tests as well

Comment by Andrea Richiardi [ 17/Dec/15 7:23 PM ]

By the way this makes me think that maybe a better choice is to consider this a side effect and directly modify cljs.analyzer/*cljs-file* returning from *load-fn*, who knows how many other spots I am not covering...

Comment by Mike Fikes [ 18/Dec/15 5:36 AM ]

Two more comments:

1) Broadening the scope of the binding doesn't appear to work properly for me. But things do work if the bindings are done as in the patch now (next to where the other bindings are done).

2) Perhaps :file should be only set if the :lang being called back with is :clj. Maybe this could at least be documented. (It is not clear to me if it is useful for :js, as the patch is setting ana/*cljs-file*.)

Comment by Andrea Richiardi [ 18/Dec/15 10:27 AM ]

About 2), is any AST generated for .js files at all? If yes maybe then we should add it too...I need to explore that code path as well.

Comment by Andrea Richiardi [ 18/Dec/15 3:33 PM ]

So basically with ana/*cljs-file* binding the :file in :meta is not changed at all (I fixed following Mike's advice) but :file is, are we ok with this? In replumb (from planck) we check both so no problem, nonetheless it would be great to know why..

:defs {foo {:protocol-inline nil, :meta {:file bootstrap-test.core, :line 3, :column 7, :end-line 3, :end-column 10, :arglists (quote ([a b]))}, :name bootstrap-test.core/foo, :variadic false, :file /.../clojurescript/src/test/self/bootstrap_test/core.cljs, :end-column 10, :method-params ([a b]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 3, :end-line 3, :max-fixed-arity 2, :fn-var true, :arglists (quote ([a b]))}}, :require-macros nil, :doc nil

Comment by Andrea Richiardi [ 18/Dec/15 3:44 PM ]

It looks like the information in :meta comes directly from the multimethod parse which I dont' think we can change easily. So either we override :file in :meta or we leave as it is with a note in the documentation for :file in *load-fn*

Comment by Andrea Richiardi [ 18/Dec/15 4:10 PM ]

About :js files at least to me it looks like the only trace of importing, say, goog.sting in the AST is in the :imports of the parent namespace. No :file key anywhere, but please correct me if I am wrong as the AST is difficult to untangle

Comment by Andrea Richiardi [ 18/Dec/15 5:29 PM ]

Patch and test

Comment by Mike Fikes [ 18/Dec/15 7:43 PM ]

Comments on {{CLJS-1515-2.patch}} (mostly just opinion):

  1. (Opinion): Introduces new public API, especially with respect to AST exposure. Perhaps fn could instead be added to the test namespace.
  2. (Opinion): I wouldn't try anything complicated to try to patch up the :file that is in the :meta map. (Maybe we'll ultimately figure out why setting cljs.analyzer/*cljs-file* is insufficient for that bit.)
  3. (Opinion): For the :file docstring, I'd avoid mentioning AST. (Even though that was the true motivation for this ticket.) I'd only indicate that it represents the location where :source was obtained. (Which I guess would leave open it being perfectly fine for clients to provide it in the case that :lang is :js.)
  4. script/test-self-host passes for me.
  5. Inadvertent whitespace changes in append-source-map.
Comment by Andrea Richiardi [ 18/Dec/15 7:49 PM ]

1. Sorry Mike I don't understand when you say fn...what do you mean? Can you expand?
2. Yes and it would change a lot of code, that's why I didn't even try
3. Ok can change that, but where should be mentioned that we are modifying :file but not inside :meta?
4. Great!
5. You know I really tried hard not to have that, I will try again to disable all the auto indent my emacs has.

Comment by Mike Fikes [ 18/Dec/15 8:30 PM ]

1. The three new public functions in cljs.js: (var-ast, ns-ast, file->lang) could perhaps be moved to be utility functions in the self-host test namespace.
3. Dunno about the :meta question. But on the :lang :js question, perhaps the patch should only bind :cljs.analyzer/*cljs-file* if :lang :clj?

Comment by Andrea Richiardi [ 18/Dec/15 8:38 PM ]

1. I know it looks like they are used in test only, but I put them there as public because both replumb and planck use them and I was kind of "proposing" this kind of AST utils to be part of the official API (so that the poor dev does not have to go through cljs.analyzer in order to query the AST. I understand if no though.
3. This I don't really know, and seek guidance. I have not noticed any significant change in the AST for .js file, maybe *cljs-file* is never queried in that code path. I could not even find a way to test it. But I could, of course, be very wrong.

Comment by Andrea Richiardi [ 21/Dec/15 2:13 PM ]

This puts the utils functions in the test namespace for now, maybe thinking about exposing some API in the future.

Comment by Andrea Richiardi [ 21/Dec/15 8:19 PM ]

About :js:

  • it looks like the analyze-str code path simply recurs to fetch the next dep. So I guess that branch does not touch the AST.
  • for the require code path it looks like it -> is -> similar.

Therefore I don't see the point in adding :file for :js and I will not bind *cljs-file* if this is the case, as you suggested.

Comment by Andrea Richiardi [ 21/Dec/15 9:48 PM ]

Patch #4 changes the conveying key to :cljs-file, after Mike's good suggestion, and moves the assoc to the (condp ... :clj) branch only. I also added a test to check that *cljs-file* does not match the file path when in the :js branch.

Comment by Andrea Richiardi [ 21/Dec/15 11:56 PM ]

Another note, the *cljs-file* test works because the binding form does not actually restore the old value when it exits...In Clojure it would not probably work.

^ This is plain wrong, I was not considering the "when" my tests are executed, please disregard.

Comment by Mike Fikes [ 23/Dec/15 5:13 PM ]

CLJS-1515-4.patch LGTM.

Details: I tested against current ClojureScript master, using downstream Planck to load regular and macro namespaces and the :file portion of the AST gets properly updated. This also occurs if I instead use cljs.js/analyze-str passing in an ns form that causes code to be loaded. Additionally unit tests (regular and bootstrap) pass for me. I think this patch is functionally good to go.

Comment by David Nolen [ 26/Dec/15 6:54 AM ]

Copying goog.string into the source tree is not desirable. Please fix the tests to remove this. If you must, copy it to a temporary a location from the Google Closure Library JAR and remove it after the test has completed, thanks.

Comment by Andrea Richiardi [ 26/Dec/15 2:20 PM ]

Patch 5 avoid copying string.js and re-uses self_host/test.js.

Comment by Andrea Richiardi [ 26/Dec/15 2:22 PM ]

Done what you asked

Comment by Mike Fikes [ 05/Feb/16 8:05 PM ]

CLJS-1515-5.patch no longer applies

Comment by Andrea Richiardi [ 14/Feb/16 9:17 PM ]

Reapplied and re-tested. Works

Testing with Node

Testing self-host.test

Ran 8 tests containing 47 assertions.
0 failures, 0 errors.
Comment by Andrea Richiardi [ 10/Aug/16 7:07 PM ]

All self-test pass!

Comment by David Nolen [ 11/Aug/16 8:11 AM ]

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





[CLJS-1732] Add docstrings for new use and use-macros REPL specials Created: 10/Aug/16  Updated: 11/Aug/16  Resolved: 11/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: docstring

Attachments: Text File CLJS-1732.patch    
Patch: Code

 Description   

To go along with CLJS-1729



 Comments   
Comment by David Nolen [ 11/Aug/16 8:10 AM ]

fixed https://github.com/clojure/clojurescript/commit/60d534977ace15667c38cf2c2609e27ad72f539a





[CLJS-1720] Self-host: Qualify symbols and namespaced keywords in spec macros Created: 31/Jul/16  Updated: 11/Aug/16  Resolved: 11/Aug/16

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

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bootstrap

Attachments: Text File CLJS-1720-2.patch     Text File CLJS-1720-3.patch     Text File CLJS-1720.patch    
Patch: Code

 Description   

There are currently a few symbols and namespaced keywords in the cljs.spec macros namespace that either need to be qualified for proper operation, or should be.

The symbols fall into the category of calls to runtime functions in the cljs.spec namespace, and need qualification in order to avoid the $macros suffix. These comprise with-gen and gen.

In terms of keywords, an example that causes a failure is ::kvs->map in keys*: It resolves to :cljs.spec$macros/kvs->map which doesn't match the :cljs.spec/kvs->map spec registered near the bottom of the cljs.spec runtime namespace.

An example that doesn't cause an outright failure, but arguably inhibits its proper use by client code is ::nil and ::pred in the nilable macro. Ideally these would resolve to :cljs.spec/nil and :cljs.spec/pred so that client code can rely on these namespaced symbols identifying the branches.

Given the nilable example, you could argue that the intent is that all namespaced keywords in the cljs.spec macro namespace that employ :: resolve in :cljs.spec so that they can be used not simply as unique identifiers (the intent is not simply to avoid potential collisions), but so that they can be used as stable identifiers.

The set of keywords that should be qualified comprises: ::kind-form, ::kfn, ::conform-all, ::kvs->map, ::nil, and ::pred



 Comments   
Comment by Mike Fikes [ 10/Aug/16 9:43 PM ]

Patch no longer applies; attaching re-baselined CLJS-1720-2.patch

Comment by Mike Fikes [ 10/Aug/16 9:55 PM ]

Sorry David, I botched that last re-baseline. Attaching a corrected CLJS-1720-3.patch.

Comment by David Nolen [ 11/Aug/16 8:09 AM ]

fixed https://github.com/clojure/clojurescript/commit/20b08fe442a24c46526c812f6c52ad8c7d3f6c9b





[CLJS-1731] Self-host: do_template problem with script/test-self-parity Created: 10/Aug/16  Updated: 11/Aug/16  Resolved: 11/Aug/16

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

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bootstrap

Attachments: Text File CLJS-1731.patch    
Patch: Code and Test

 Description   
Testing cljs.spec-test

ERROR in (conform-explain) (TypeError:NaN:NaN)
Uncaught exception, not in assertion.
expected: nil
  actual: #object[TypeError TypeError: Cannot read property 'do_template' of undefined]


 Comments   
Comment by Mike Fikes [ 10/Aug/16 4:04 PM ]

The attached patch makes some slight adjustments to the self-host parity unit test namespace loading logic so that it can successfully load the clojure.template namespace.

Note that the patch fixes this issue, but at the same time it reveals that there are now 6 new test failures related to cljs.spec.

Comment by Mike Fikes [ 10/Aug/16 10:05 PM ]

Good news: The changes in CLJS-1720 cover the newly failing unit tests mentioned above.

Comment by David Nolen [ 11/Aug/16 8:08 AM ]

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





[CLJS-1734] :import in ns silently discards imported classes with the same name Created: 11/Aug/16  Updated: 11/Aug/16

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

Type: Defect Priority: Minor
Reporter: Thomas Heller Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   
(ns some.ns
  (:import goog.fx.Transition.EventType
           goog.history.EventType))

Both classes are named EventType and the second will effectively remove the first one without warning or error.






[CLJS-1630] Add unit test for static dispatch Created: 21/Apr/16  Updated: 10/Aug/16

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: 1.7.228
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Yehonathan Sharvit Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File CLJS-1630.patch    

 Description   

This unit test is an edge case that illustrates why in the code of `emit :invoke` we must stay with `call` for the high order case where static information is missing .



 Comments   
Comment by Yehonathan Sharvit [ 10/Aug/16 10:52 PM ]

Could someone take a look at this unit test?





[CLJS-1665] Use Javascript array to create a collection in cljs.reader Created: 03/Jun/16  Updated: 10/Aug/16  Resolved: 10/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: Rohit Aggarwal Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: performance

Attachments: Text File CLJS-1665.patch    
Patch: Code

 Description   

For performance, we should be using a Javascript array to create an ArrayMap/HashMap/Set/List/Vector instead of creating them out of a Vector. Most of the underlying data types do have methods to convert from an array to that type.

The big change is that cljs.reader/read-delimited-list now returns an array instead of a vector.

Benchmarking code:

(def nums (range 20))
(def nums-map (into {} (map (fn [i] [i i]) nums)))

(simple-benchmark [s "{:foo 1 :bar 2}"] (reader/read-string s) 1000000)
(simple-benchmark [s (pr-str nums-map)] (reader/read-string s) 100000)
(simple-benchmark [s (pr-str nums)] (reader/read-string s) 100000)
(simple-benchmark [s (pr-str (vec nums))] (reader/read-string s) 100000)
(simple-benchmark [s (pr-str (set nums))] (reader/read-string s) 100000)

Results (All times in msecs):

Engine Benchmark Old New Improvement
v8 Small Map 6620 5516 20.01%
SpiderMonkey Small Map 11929 10606 12.47%
JSC Small Map 5101 4158 22.68%
v8 Large Map 6075 5548 9.50%
SpiderMonkey Large Map 13070 11933 9.53%
JSC Large Map 4777 4273 11.79%
v8 List 2308 2280 1.23%
SpiderMonkey List 6167 4777 29.10%
JSC List 1891 1737 8.87%
v8 Vector 2276 2242 1.52%
SpiderMonkey Vector 5239 4700 11.47%
JSC Vector 1832 1684 8.79%
v8 Set 3362 3271 2.78%
SpiderMonkey Set 7283 6880 5.86%
JSC Set 2771 2619 5.80%


 Comments   
Comment by David Nolen [ 10/Aug/16 2:24 PM ]

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

Comment by Rohit Aggarwal [ 10/Aug/16 3:00 PM ]

Thank you David!





[CLJS-1186] add :postamble option to compiler Created: 02/Apr/15  Updated: 10/Aug/16  Resolved: 10/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: Michael Bradley Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: cljs

Attachments: Text File cljs_1186.patch    

 Description   

Similar to CLJS-723:

1) :postamble's value will be a vector of paths
2) the compiled output is appended with the contents of the files at those paths
3) the generated source map points to the correct/adjusted line numbers



 Comments   
Comment by David Nolen [ 12/Feb/16 4:42 PM ]

Would like to hear more use cases for this one.

Comment by David Nolen [ 10/Aug/16 2:42 PM ]

Not going to do this one.





[CLJS-1556] Invalid code emit for obj literal Created: 31/Jan/16  Updated: 10/Aug/16  Resolved: 10/Aug/16

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

Type: Defect Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1556.patch    
Patch: Code and Test

 Description   

For some legal ClojureScript expressions involving #js object literals, invalid JavaScript is emitted. Specifically this has to do with object literals appearing at the beginning of statements where the opening brace can be interpreted as the beginning of a JavaScript block.

One way to reproduce this is to evaluate

(do #js {:a 1} 
    #js {:b 2})

in the Node REPL. In this case it is the first object literal that causes the problem; the second one emitted follows a return statement and is OK.

Rationale for marking it as minor: This appears to only really occur in places where the object literal won't actually be used.



 Comments   
Comment by David Nolen [ 10/Aug/16 2:38 PM ]

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





[CLJS-1607] bug with `specify!` in JS prototypes with `static-fns` true Created: 23/Mar/16  Updated: 10/Aug/16  Resolved: 10/Aug/16

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

Type: Defect Priority: Minor
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Completed Votes: 2
Labels: None
Environment:

affects 1.8.34


Attachments: Text File CLJS-1607.patch    
Patch: Code and Test

 Description   

compiling this code with `:static-fns` true

(ns bug.core)

(defprotocol IBug
  (bug [this other] "A sample protocol"))

(defn MyBug [])
(specify! (.-prototype MyBug)
  IBug
  (bug [this other]
    "bug")
  Object
  (foo [this]
    (bug this 3))) ;; line 13

causes the following warning:

WARNING: Use of undeclared Var bug.core/x14072 at line 13


 Comments   
Comment by António Nuno Monteiro [ 23/Mar/16 1:42 PM ]

narrowed it down to this line (https://github.com/clojure/clojurescript/blob/f0ac4c92006ac618516c11e9ca3527904d35d4af/src/main/clojure/cljs/compiler.cljc#L936) being called in `:advanced` because it passes the check of cljs-static-fns in that case

Comment by António Nuno Monteiro [ 29/Jul/16 7:16 AM ]

Upon further investigation, this is actually specific to `:static-fns true`, not advanced compilation.

Comment by António Nuno Monteiro [ 29/Jul/16 9:15 AM ]

Attached patch with fix and test.

Comment by David Nolen [ 10/Aug/16 2:36 PM ]

fixed https://github.com/clojure/clojurescript/commit/273bcd33522b085fe98948598528fcf2c90a778c





[CLJS-1591] Compilation time go up significantly when nesting multimethods Created: 25/Feb/16  Updated: 10/Aug/16  Resolved: 10/Aug/16

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

Type: Defect Priority: Minor
Reporter: Marian Schubert Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: cljs, compiler

Attachments: Text File CLJS-1591.patch    

 Description   

Code like this takes 140 seconds to compile on my machine. Regular functions don't seem to trigger this behaviour.

(ns slow.core)

(defmulti my-multimethod (fn [x] :whatever))

(defn this-is-sloow-to-compile []
  (my-multimethod
   (my-multimethod
    (my-multimethod
     (my-multimethod
      (my-multimethod
       (my-multimethod
        (my-multimethod
         (my-multimethod
          (my-multimethod
           (my-multimethod
            (my-multimethod
             (my-multimethod
              (my-multimethod
               (my-multimethod
                (my-multimethod
                 (my-multimethod
                  (my-multimethod
                   (my-multimethod
                    (my-multimethod
                     (my-multimethod {})))))))))))))))))))))

$ rm -rf target/ && ./scripts/release 
Building ...
Analyzing jar:file:/Users/maio/.m2/repository/org/clojure/clojurescript/1.7.228/clojurescript-1.7.228.jar!/cljs/core.cljs
Compiling src/slow/core.cljs        <-- here it spends most of the time
Applying optimizations :advanced to 11 sources
... done. Elapsed 141.85386191 seconds

Whole project is here https://github.com/maio/slow-cljs-build



 Comments   
Comment by Mike Fikes [ 04/Mar/16 4:32 PM ]

Hrm. This fix is evidently in the Closure compiler used by 1.7.228: https://github.com/google/closure-compiler/issues/1049

Comment by Thomas Heller [ 06/Mar/16 6:25 AM ]

@mfikes the slowdown is not related to the Closure Compiler since it happens when compiling cljs->js not when optimizing.

The reason for the slowdown is due to the arguments of a multimethod call being analyzed twice (or more in case of deep nesting).

See [1] for the problematic code.

multimethods are not fn-var? so the or does not short circuit and (all-values? argexprs) is reached. This forces the argexprs lazy-seq (thereby analyzing the args). Since the args are not all-values? the else-branch of the if is taken, which then later causes the args to be analyzed again. My math is weak but I'm not mistaken this is O(n!), explaining the dramatic slowdown.

Every var that is not fn-var? is affected by this:

(defn test [& args] :whatever)
(def my-multimethod test)
;; or
(def my-multimethod
  (reify
    IFn
    (-invoke [a] :whatever)))

One solution would be to fix all-values? that instead of running through analyze it could just check whether all args are fixed literals (ie. not list? but all of number? string? symbol? keyword? etc.).

I'm not really sure why the else-branch in [1] exists at all but I assume it is to work around some JS quirks. I will hold off on writing a patch until I figure out why the extra let introduced in the else-branch is needed.

[1] https://github.com/clojure/clojurescript/blob/f58dcdf4dc37ef52d4eb1e2b7c994282bf6351f5/src/main/clojure/cljs/analyzer.cljc#L2257-L2263

PS: forgot to add that this does not happen with :static-fns false since it also prevents the else from being reached.

Comment by Thomas Heller [ 06/Mar/16 6:55 AM ]

The else was introduced in CLJS-855 and is sort of required for invokes without arity information and :static-fns true.

Changing all-values? to just check literals instead of analyzing should be a valid solution.

Comment by Thomas Heller [ 14/Mar/16 8:31 AM ]

The patch removes the extra analyze and instead just checks the few cases that can actually be used without assignment first.

This removes the slowdown while keeping all the functionality.

Comment by David Nolen [ 10/Aug/16 2:32 PM ]

fixed https://github.com/clojure/clojurescript/commit/1589e5848ebb56ab451cb73f955dbc0b01e7aba0





[CLJS-1713] cljs.spec/explain-data returns different data structure than clojure.spec/explain-data Created: 24/Jul/16  Updated: 10/Aug/16  Resolved: 10/Aug/16

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

Type: Defect Priority: Minor
Reporter: Marshall Abrams Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: spec
Environment:

Tested in Clojure 1.9.0-alpha10 and Clojurescript 1.9.89



 Description   

The structure of the data returned by cljs.spec/explain-data seems to be unnecessarily different from the structure of data returned by clojure.spec/explain-data. Since, as I understand it, explain.data is mean to be used programmatically, this means that code has to be changed, unnecessarily, it seems, to work with both dialects.

Ignoring trivial differences that are to be expected going from one dialect to the other, in Clojure, the value of the top-level key :problems is a sequence of maps, each of which includes a :path key and value. In Clojurescript, the value of :problems is a map in which those vectors that were the values of :path in Clojure are instead keys, whose values are the rest of the corresponding Clojure maps.

Example:

(s/def ::a #(> % 0))
(s/def ::b (s/or :lt0 #(< % 0.0) :gt1 #(> % 1.0)))
(s/def ::all (s/keys :req-un [::a ::b]))
(s/explain ::all {:a -1 :b 0.5})
(pprint (s/explain-data ::all {:a -1 :b 0.5}))

In Clojure 1.9.0-alpha10, the last line returns:

#:clojure.spec{:problems ({:path [:a], :pred (> % 0), :val -1, :via [:user/all :user/a], :in [:a]}
                          {:path [:b :lt0], :pred (< % 0.0), :val 0.5, :via [:user/all :user/b], :in [:b]}
                          {:path [:b :gt1], :pred (> % 1.0), :val 0.5, :via [:user/all :user/b], :in [:b]})}

In Clojurescript 1.9.89, the same line returns:

{:cljs.spec/problems {[:a] {:pred (> % 0), :val -1, :via [:cljs.user/all :cljs.user/a], :in [:a]}, 
                      [:b :lt0] {:pred (< % 0), :val 0.5, :via [:cljs.user/all :cljs.user/b], :in [:b]},
                      [:b :gt1] {:pred (> % 1), :val 0.5, :via [:cljs.user/all :cljs.user/b], :in [:b]}}}


 Comments   
Comment by Marshall Abrams [ 24/Jul/16 11:58 AM ]

I just realized that Clojurescript 1.9.89 is still based on Clojure 1.9.0-alpha7, in which the data structure is like in the Clojurescript last example above. That explains the difference in the examples, and I assume that the explain-data return values will eventually be harmonized between the dialects, with future releases of Clojurescript (possibly after further changes in Clojure's explain-data return values, since this seems to be in flux). Apologies if this is just a "noise" ticket that shouldn't have been opened.

Comment by David Nolen [ 10/Aug/16 2:18 PM ]

fixed in master





[CLJS-1638] :elide-asserts disables atom validators in :advanced Created: 07/May/16  Updated: 10/Aug/16  Resolved: 10/Aug/16

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

Type: Defect Priority: Major
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1638.patch    
Patch: Code and Test

 Description   

Background: In Clojure, *assert* does not affect atom validators.

$ java -jar cljs.jar
Clojure 1.8.0
user=> (set! *assert* false)
false
user=> (let [a (atom 1 :validator pos?)]
    (reset! a 0)
    (println @a))
IllegalStateException Invalid reference state  clojure.lang.ARef.validate (ARef.java:33)

In ClojureScript, :elide-asserts affects atom validators, but only in :advanced:

build.clj:

(require 'cljs.build.api)

(cljs.build.api/build "src" 
  {:main          'foo.core
   :target        :nodejs
   :output-to     "main.js"
   :optimizations :advanced
   :elide-asserts true})

(System/exit 0)

src/foo/core.cljs:

(ns foo.core
  (:require [cljs.nodejs :as nodejs]))

(nodejs/enable-util-print!)

(defn -main [& args]
  (let [a (atom 1 :validator pos?)]
    (reset! a 0)
    (println @a)))

(set! *main-cli-fn* -main)

Build with: java -cp cljs.jar:src clojure.main build.clj
Run with node main.js

You will see that with :advanced, the code prints 0, but with :none the atom validator rejects the reset! attempt.



 Comments   
Comment by Mike Fikes [ 07/May/16 9:33 PM ]

Attached CLJS-1638.patch.

Note: Even though the patch adds a new test, the test simply excercises triggering atom validator behavior (to help ensure no regression). Since we don't have tests built with :elide-asserts true, to confirm the fix, you need to manually run through the repro in this ticket's description.

The patch does not attempt to fuse the resulting two nested when-not constructs so as to preserve the outer fast JavaScript null check emitted which tests if a validator has been set—the intent being to preserve fast path behavior in the common case of not having a validator.

Comment by David Nolen [ 10/Aug/16 2:14 PM ]

fixed https://github.com/clojure/clojurescript/commit/73e99298cc19569855de40eeb6ab1c21d25987b3





[CLJS-1640] Use the unshaded version of the closure compiler Created: 16/May/16  Updated: 10/Aug/16  Resolved: 10/Aug/16

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

Type: Defect Priority: Major
Reporter: Mike Kaplinskiy Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None


 Description   

The current version of clojurescript (1.8.51) depends on [com.google.javascript/closure-compiler "v20160315"]. That artifact is actually a fat jar - it includes all the dependencies (including guava & protobuf). This causes duplicate class warnings in some tools.

There was a recent change in the closure compiler that created an unshaded artifact [com.google.javascript/closure-compiler-unshaded "v20160315"] that doesn't bundle it's dependencies. It would be nice if clojurescript changed it's dependency to that one



 Comments   
Comment by David Nolen [ 21/May/16 5:04 PM ]

Thanks for bringing this up. Sounds like a good idea.

Comment by David Nolen [ 10/Aug/16 2:12 PM ]

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





[CLJS-1721] 3-arity get-in fails on types which do not implement ILookup Created: 02/Aug/16  Updated: 10/Aug/16  Resolved: 10/Aug/16

Status: Resolved
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Thomas Mulvaney Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1721.patch    

 Description   

The following are examples which fail:

(get-in {:a "data"} [:a 0] :not-found)
(get-in {:a (array 0 1 2 3)} [:a 0] :not-found)

Whilst the 2-arity version succeeds.



 Comments   
Comment by Thomas Mulvaney [ 04/Aug/16 7:57 AM ]

Also worth noting that the 3-arity version is quicker than the 2-arity version on long paths because it bails when a lookup fails. For example (get-in {} [:a :b :c :d :e :f]) is slower than (get-in {} [:a :b :c :d :e :f] :not-found) which bails out as soon a lookup fails. The former continues to call `get` on nil for the rest of the keys.

Perhaps it would be better for the 2-arity version to make a call to the 3-arity version passing nil as the last argument to take advantage of the early return. Would be happy to update the patch to include this.

Comment by David Nolen [ 10/Aug/16 1:51 PM ]

fixed https://github.com/clojure/clojurescript/commit/817b44d34795696eda473776e355fb956d3aa5ae





[CLJS-1728] Update doc for ns for new :rename capability Created: 09/Aug/16  Updated: 10/Aug/16  Resolved: 10/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: docstring

Attachments: Text File CLJS-1728.patch    
Patch: Code

 Description   

Update the docstring for the ns special to cover the :rename option landed with CLJS-1508.



 Comments   
Comment by David Nolen [ 10/Aug/16 1:43 PM ]

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





[CLJS-1729] Support `use` special function in REPLs Created: 10/Aug/16  Updated: 10/Aug/16  Resolved: 10/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1729.patch    
Patch: Code

 Description   

While `:use` is supported at the NS declaration level, REPLs only support `import` and `require`.

Supporting `use` and `use-macros` in REPLs would be a useful addition.



 Comments   
Comment by António Nuno Monteiro [ 10/Aug/16 11:00 AM ]

Attached patch with fix

Comment by David Nolen [ 10/Aug/16 1:42 PM ]

fixed https://github.com/clojure/clojurescript/commit/8c6bbf8bc9f5b3e04fd8b172e725894256076e75





[CLJS-1508] Extend ns form to support :rename option Created: 09/Dec/15  Updated: 09/Aug/16  Resolved: 09/Aug/16

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

Type: Enhancement Priority: Major
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 1
Labels: None

Attachments: Text File CLJS-1508-1.patch     Text File CLJS-1508.patch    
Patch: Code and Test

 Description   

Support a :rename option to :require. Following :rename should be a map of symbol to symbol. Refer to clojure.core/refer for semantics with respect to this allowing avoidance of clashes.

An REPL example:

(require '[fipp.edn :refer (pprint) :rename {pprint fipp}])


 Comments   
Comment by António Nuno Monteiro [ 01/Aug/16 7:24 AM ]

Added patch with fix and tests.

I'd appreciate some initial feedback on this one.

Comment by David Nolen [ 08/Aug/16 7:51 AM ]

Flowing a new kind of value (maps) through this code seems like a big complication in an area where the code is already not particularly straightforward. I would also be a little concerned about downstream complexity (other people also have to make this check if using the analyzer for some reason).

Comment by António Nuno Monteiro [ 09/Aug/16 1:18 PM ]

Attached CLJS-1508-1.patch which takes feedback into account

Comment by David Nolen [ 09/Aug/16 4:26 PM ]

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





[CLJS-1350] Compiler support for browser REPL Created: 19/Jul/15  Updated: 09/Aug/16  Resolved: 09/Aug/16

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

Type: Enhancement Priority: Major
Reporter: David Nolen Assignee: Unassigned
Resolution: Completed Votes: 2
Labels: None


 Description   

Currently the browser REPL experience could be considerably enhanced just by eliminating manual configuration in source. Instead REPL configuration could happen via a compiler option. This would make REPL support considerably more robust in the face of user errors while developing.



 Comments   
Comment by David Nolen [ 09/Aug/16 4:15 PM ]

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





[CLJS-1723] pr-writer-ex-info does not print false values and tries to reimplement map printer Created: 04/Aug/16  Updated: 08/Aug/16

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

Type: Defect Priority: Trivial
Reporter: Antonin Hildebrand Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File CLJS-1723.patch    
Patch: Code

 Description   

While working on CLJS-1722 I spotted two issues with pr-writer-ex-info:

1) if data or cause happen to be "false", they are skipped in printing
2) the code tries to mimic map printer

This patch fixes both issues. It turns out printing real info map yields exactly same string output and plays better with cljs-devtools printer (which newly sees real map instead of soup of strings and values).

For reference: pr-writer-ex-info was implemented in CLJS-983



 Comments   
Comment by David Nolen [ 08/Aug/16 7:39 AM ]

Can you explain why you think 1 is a problem? data should be a map. cause should be an error but I suppose that could be a problem if you have a rethrow which wraps some throwable value (which of course could be anything).

Comment by Antonin Hildebrand [ 08/Aug/16 2:32 PM ]

Disclaimer: I don't have much experience with Clojure and almost none with Java.

Just by reading the code I didn't see any checks in ex-info (or in ExceptionInfo ctor) to restrict data or cause. So I assumed anything can be passed in and printer should print it as-is without additional logic. I assumed that checking for nil values was intentional abbreviation when CLJS-983 was implemented. And I assumed that false value was supposed to be printed. At least I personally would want it to be distinguished from nil. Or there should be no abbreviation at all.





[CLJS-1727] Regression when evaluating non-sequential forms at the REPL Created: 05/Aug/16  Updated: 08/Aug/16  Resolved: 08/Aug/16

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

Type: Defect Priority: Major
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None
Environment:

Affects master as of commit 8524d7b1ac7c1c418ec394e89322e341070414ca


Attachments: Text File CLJS-1727.patch    
Patch: Code

 Description   

this commit [1] assumes that the forms evaluated at the REPL are always sequential by comparing `(first form)` with 'ns.
This makes it impossible to evaluate e.g. numbers or symbols.

[1]: https://github.com/clojure/clojurescript/commit/8524d7b1ac7c1c418ec394e89322e341070414ca



 Comments   
Comment by António Nuno Monteiro [ 05/Aug/16 7:39 AM ]

Attached patch with fix.

Comment by David Nolen [ 08/Aug/16 7:36 AM ]

fixed https://github.com/clojure/clojurescript/commit/2cc8f921cb1e56dbeb901e61a7149d283ad78bc7





[CLJS-884] with-redefs don't restores previous values when used inside go block Created: 09/Nov/14  Updated: 07/Aug/16

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

Type: Defect Priority: Trivial
Reporter: Vladimir Iakovlev Assignee: Unassigned
Resolution: Unresolved Votes: 4
Labels: None
Environment:

clojure 1.6, clojurescript 0.0-2371, core.async 0.1.346.0-17112a-alpha


Attachments: Text File cljs_884.patch    

 Description   

For example I have code and test:

(defn test-fn [] :original)

(deftest ^:async test-with-redefs-async
  (go (is (= (test-fn) :original))
      (with-redefs [test-fn (fn [] :mocked)]
        (is (= (test-fn) :mocked)))
      (is (= (test-fn) :original))
      (done)))

And test failed in last `is`:

FAIL in (test-with-redefs-async) (:)
expected: (= (test-fn) :original)
  actual: (not (= :mocked :original))


 Comments   
Comment by Vladimir Iakovlev [ 09/Nov/14 1:26 PM ]

I attached little patch with fix. With it `with-redefs` forced to use previous value for restoring bindings.

But I don't know how to add test for this issue, because it requires core.async. So I tested with:

(defn test-fn [] :original)

(deftest test-with-redefs-sync
  (is (= (test-fn) :original))
  (with-redefs [test-fn (fn [] :mocked)]
    (is (= (test-fn) :mocked)))
  (is (= (test-fn) :original)))

(deftest ^:async test-with-redefs-async
  (go (is (= (test-fn) :original))
      (with-redefs [test-fn (fn [] :mocked)]
        (is (= (test-fn) :mocked)))
      (is (= (test-fn) :original))
      (done)))
Comment by Yehonathan Sharvit [ 07/Aug/16 2:49 AM ]

Why this bug is not adressed?

Comment by Antonin Hildebrand [ 07/Aug/16 4:57 PM ]

It might be related to CLJS-1634. The likely reason: it is technically very hard to solve without paying non-negligible runtime price for it.

Comment by Yehonathan Sharvit [ 07/Aug/16 11:26 PM ]

The problem mentioned in http://dev.clojure.org/jira/browse/CLJS-1634 is much wider.

The current issue only deals with the fact that `with-redefs` doen't restore previous values when used inside go block.

There is a very simple solution to this specific issue here: https://nvbn.github.io/2014/11/05/protocols-for-testing/ (also written by Vladimir).





[CLJS-1726] demunge is too agreesive and incorrect in some cases Created: 04/Aug/16  Updated: 04/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: Antonin Hildebrand Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I have implemented some "demunging" logic in cljs-devtools (and dirac) to present original user-friendly names in UI.

During my testing I spotted some wrong edge-cases and incorrect behaviours of demunge:

1) it is too aggressive in replacing dollars - some dollars can be "real" dollars as part of original name
2) it does not revert js-reserved? transformation applied during munging
3) it is oblivious to underscores/dashes - some underscores were "real" underscores before munging
(this may be not complete)

I have worked around those issues on my side and implemented some heuristics[1] based on context, but it is far from perfect.

I'm not sure how to properly fix those, so I wanted to open a ticket with discussion. Maybe people will have some clever ideas.

Currently munging is lossy and we probably don't want to touch it for compatibility reasons.
Maybe we could mark original underscores and dollars in some way, so demunge could properly skip them.

1) One strategy could be to use some (rare) unicode characters, but that would be problematic for people to type.
2) Another strategy could be to escape original dollars and underscores somehow (using more dollars and underscores .
3) Better ideas?

[1] https://github.com/binaryage/cljs-devtools/blob/52899e61e33373df36be8dcb23c69377936821b2/src/lib/devtools/munging.cljs#L154-L185






[CLJS-1725] defrecord does not set cljs$lang$ctorStr Created: 04/Aug/16  Updated: 04/Aug/16

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

Type: Defect Priority: Trivial
Reporter: Antonin Hildebrand Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File CLJS-1725.patch    
Patch: Code and Test

 Description   

While implementing some demunging code[1] for cljs-devtools, I stumbled upon inconsistency in type->str. It works for deftypes but not for defrecords.

The problem is that defrecord does not set! cljs$lang$ctorStr field for some reason. This has been likely overlooked, because type->str is not used often, just for some rare error exceptions as far I can see.

Anyways, this patch fixes it by copy&pasting it from deftype. A better solution to avoid future problems like this would be to extract shared code between deftypes and defrecords, but that seems to be a lot of work.

The patch also adds some tests. I had to add some utility macros to run those tests only in simple mode, because type->str is not supposed to work under advanced builds.
Also test for CLJS-1722 was added to be uncommented after potentially merging it.

[1] https://github.com/binaryage/cljs-devtools/blob/52899e61e33373df36be8dcb23c69377936821b2/src/lib/devtools/munging.cljs#L56-L60






[CLJS-1724] Include IIterable in fast-path-protocols Created: 04/Aug/16  Updated: 04/Aug/16

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

Type: Enhancement Priority: Trivial
Reporter: Antonin Hildebrand Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File CLJS-1724.patch    

 Description   

While exploring CLJS record instances printed via cljs-devtools v0.8.0, I spotted that IIterable is not a fast-path protocol:

https://dl.dropboxusercontent.com/u/559047/iiterable-slow-path.png

Please notice that IIterable is the only white label in the protocol list there.






[CLJS-1722] Upgrade ExceptionInfo to proper deftype Created: 03/Aug/16  Updated: 04/Aug/16

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

Type: Enhancement Priority: Minor
Reporter: Antonin Hildebrand Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File CLJS-1722.patch    
Patch: Code

 Description   

Currently ExceptionInfo is implemented as a raw constructor function which inherits from js/Error with some ad-hoc javascript-level patches to satisfy a tiny subset of deftype functionality (mainly for printing).

Unfortunately this does not play well with cljs-devtools[1]. This problem surfaced when I started playing with ExceptionInfo and cljs-devtools v0.8 which newly supports printing deftypes[2]. ExceptionInfo does not contain getBasis, cljs$lang$type, cljs$lang$ctorStr and similar machinery.

My proposed patch implements ExceptionInfo as a proper deftype and does some patch-work to provide backward compatibility. I'm pretty sure we must not break current contract of ExceptionInfo constructor accepting 3 args and synthesizing other fields on the fly in constructor.

Implementation details:
1) first we define ExceptionInfo as normal deftype (to get a template)
2) then we remember reference to ExceptionInfo in ExceptionInfoTypeTemplate
3) then we redefine ExceptionInfo with raw constructor function which should mimic original behaviour (by scraping newly created js/Error instance, but calling ExceptionInfoTypeTemplate to do proper deftype initialization)
4) then we copy keys from ExceptionInfoTypeTemplate over ExceptionInfo
5) then we set ExceptionInfo's prototype to be ExceptionInfoTypeTemplate's prototype
6) then we fix ExceptionInfo's prototype's constructor to point to our re-defined constructor function
7) then we patch ExceptionInfo's prototype to inherit from js/Error (note this clobbers ExceptionInfoTypeTemplate as well - but we don't care about it)

This effectively gives us properly working ExceptionInfo deftype with redefined constructor function wrapping deftype's constructor for backwards compatibility.
We also patch ExceptionInfo's prototype to inherit from js/Error the same was as original code did.

Note: With working deftype, we can move IPrintWithWriter and toString implementation to the deftype itself.

[1] https://github.com/binaryage/cljs-devtools/issues/23
[2] https://github.com/binaryage/cljs-devtools/releases/tag/v0.8.0



 Comments   
Comment by Thomas Heller [ 04/Aug/16 4:25 AM ]

Why not just add the missing getBasis, cljs$lang$type, cljs$lang$ctorStr bits per set!?

The patch looks like it would mess up advanced compilation although that is just an instinct not something I verified, did you?

Comment by Antonin Hildebrand [ 04/Aug/16 4:44 AM ]

I ran clojurescript tests and I assumed they run also against advanced-mode build. During development when my tests were failing I saw error messages about minified names.

This may seem as a hacky solution, but IMO the original code was also a hack. My hack will stay up-to-date with future changes to deftype implementation. I can imagine people would forget to update this part when touching deftype.

btw. there is another patch coming related to discrepancies between deftype and defrecord. That could have been avoided if defrecord shared common implementation with deftype.

Comment by Thomas Heller [ 04/Aug/16 6:27 AM ]

Closure is usually very strict about re-defining stuff but I guess my instincts were wrong, the tests should cover advanced.

My issue with this is that deftype is for defining Clojure-specific types. ExceptionInfo is not since it inherits from Error, just like you can't have a superclass in Clojure you can't in CLJS. So IF we were to change deftype in the future we might break things in unexpected ways that just re-use deftype but aren't actually deftype.

Yes, you have to do some house-keeping but you can't enforce the rules of deftype when dealing with inheritance.

Just my 2 cents, it has advantages to re-use deftype too (as you suggested).

Comment by Antonin Hildebrand [ 04/Aug/16 6:36 AM ]

Unfortunately I was unable to look up any comments or docs explaining the reasoning why we do that js/Error inheritance there.

My first attempt to "fix" ExceptionInfo was to simply implement it as an ordinary deftype. And that worked just fine (for my tests). Then I tried to re-implement original behaviours on top just to make it 100% compatible.

Comment by Antonin Hildebrand [ 04/Aug/16 12:47 PM ]

Just adding a motivational screenshot:

https://dl.dropboxusercontent.com/u/559047/CLJS-1722-example.png

Those yellow warnings are listing which properties are getting copied by gobject/extend call.
The expanded log item is new implementation logged via cljs-devtools v0.8.0.
The last log item is the old implementation logged via cljs-devtools v0.8.0 (cljs-devtools does not recognise ExceptionInfo as CLJS type, but detects IPrintWithWriter and uses it to present the value)





[CLJS-1474] Error if reserved symbol is defined Created: 21/Oct/15  Updated: 31/Jul/16

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

Type: Enhancement Priority: Minor
Reporter: Martin Klepsch Assignee: David Nolen
Resolution: Unresolved Votes: 0
Labels: newbie

Attachments: Text File CLJS-1474.patch    
Patch: Code and Test

 Description   

Currently a definition like

(defn set! [] ...)

will not cause any warning. Any usage of it (without :as namespace aliasing) however will not use the defined var but the set! special form.

A warning seems appropriate.



 Comments   
Comment by António Nuno Monteiro [ 30/Jul/16 1:19 PM ]

Attached patch with fix and test.

Comment by Mike Fikes [ 31/Jul/16 2:09 PM ]

I know David suggested that a hard error is probably the right thing to do for this one, but one consequence is that the cljs.spec/def macro cannot be defined in bootstrap with this change. (I haven't investigated thoroughly, but this may simply be the result of macros being processed as ClojureScript in bootstrap, and thus being subject to this new guard.)

Regardless of the root cause, you'll see this if you try to run script/test-self-parity:

#error {:message "Could not eval cljs.spec", :data {:tag :cljs/analysis-error}, :cause #error {:message "Can't def special form at line 51 ", :data {:file nil, :line 51, :column 1, :tag :cljs/analysis-error}}}

For reference: Line 51 currently points at the def macro: https://github.com/clojure/clojurescript/blob/e2db5d9ff8cb6a099ebc2a8cd379385bf4649b38/src/main/cljs/cljs/spec.cljc#L51





[CLJS-1636] Mark some symbols in core macros ns as private Created: 27/Apr/16  Updated: 31/Jul/16

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

Type: Enhancement Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File CLJS-1636-2.patch     Text File CLJS-1636.patch    
Patch: Code

 Description   

There are some symbols in the core macros namespace that are not meant for external consumption. Some of these are marked private and some aren't. This ticket asks that the others be marked private as well.

An example of one symbol marked private is defcurried.
An example of one symbol not marked private is caching-hash.



 Comments   
Comment by Mike Fikes [ 27/Apr/16 8:21 AM ]

In CLJS-1636.patch, I checked and it appears nothing in the compiler codebase is explicitly using these symbols outside of the cljs.core namespace. But, it is still worth scanning through these to check if they make sense. For example js-debugger and js-comment are a couple that might actually be meant for public use, but it is difficult to tell.

Comment by Mike Fikes [ 27/Apr/16 2:43 PM ]

Note, that in #cljs-dev slack, there appears to be interest in caching-hash being public.

(I don't mind revising the patch to suit whatever is needed. At the same time, I'm certainly not in a position to take decisions on what is public API or not.)

Comment by Mike Fikes [ 27/Apr/16 2:43 PM ]

Note, that in #cljs-dev slack, there appears to be interest in caching-hash being public.

(I don't mind revising the patch to suit whatever is needed. At the same time, I'm certainly not in a position to take decisions on what is public API or not.)

Comment by Mike Fikes [ 31/Jul/16 1:33 PM ]

Patch no longer applies. Attaching updated patch.





[CLJS-1490] Watch macro files in cljs.build.api/watch Created: 23/Nov/15  Updated: 30/Jul/16  Resolved: 30/Jul/16

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

Type: Enhancement Priority: Minor
Reporter: Sebastian Bensusan Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1490.patch    
Patch: Code

 Description   

The cljs.build.api/watch function is great for writing scripts or tooling but it doesn't track .clj macro files as noted in here. Direct users face unexpected behavior and tooling developers need to reimplement the watch functionality.

The undesired behavior can be tested with this repo (instructions there).

I propose to add the functionality into the watch function, or at least propose a mechanism so that tooling authors can reuse the functionality.



 Comments   
Comment by David Nolen [ 24/Nov/15 12:00 PM ]

Happy to see a fix for this.

Comment by António Nuno Monteiro [ 30/Jul/16 12:30 PM ]

Attached patch with fix.

Comment by David Nolen [ 30/Jul/16 12:39 PM ]

fixed https://github.com/clojure/clojurescript/commit/2267a8e5e9607aff8c940fa372dbdb35816350ba





[CLJS-1160] Source map js / cljs line number mixup Created: 23/Mar/15  Updated: 30/Jul/16  Resolved: 30/Jul/16

Status: Closed
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: Not Reproducible Votes: 0
Labels: None
Environment:

QuickStart Browser REPL Chrome OS X



 Description   

Note the source location for cljs.core.LazySeq.sval in the following 0.0-3126 stacktrace:

ClojureScript:cljs.user> (map ffirst (range))
Error: 0 is not ISeqable
	 cljs$core$seq (out/cljs/core.cljs:951:13)
	 cljs$core$first (out/cljs/core.cljs:960:7)
	 cljs$core$ffirst (out/cljs/core.cljs:1393:3)
	 cljs.core.map.cljs$core$map__2 (out/cljs/core.cljs:4046:30)
	 cljs.core.LazySeq.sval (out/cljs/core.cljs:11400:3)
	 cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (out/cljs/core.cljs:2884:12)
	 cljs$core$seq (out/cljs/core.cljs:938:7)
	 cljs$core$pr_sequential_writer (out/cljs/core.cljs:8426:13)

It turns out that line 11400 is actually in core.js, but the source map logic is evidently getting tripped up by this one, and core.cljs gets reported with the JS line numbers (core.cljs doesn't even have that many lines).

Note that this also occurs on master (where CLJS-1154 and CLJS-1157 have landed):

ClojureScript:cljs.user> (map ffirst (range))
Error: 0 is not ISeqable
	 cljs.core/seq (out/cljs/core.cljs:951:20)
	 cljs.core/first (out/cljs/core.cljs:960:16)
	 cljs$core$ffirst (out/cljs/core.cljs:1393:11)
	 cljs.core.map.cljs$core$map__2 (out/cljs/core.cljs:4046:30)
	 cljs.core.LazySeq.sval (out/cljs/core.cljs:11400:3)
	 cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (out/cljs/core.cljs:2884:12)
	 cljs.core/seq (out/cljs/core.cljs:938:25)
	 cljs$core$pr_sequential_writer (out/cljs/core.cljs:8426:20)


 Comments   
Comment by António Nuno Monteiro [ 30/Jul/16 9:32 AM ]

Can no longer repro on 1.9.89

cljs.user=> (map ffirst (range))
Error: 0 is not ISeqable
	 cljs.core/seq (out/cljs/core.cljs:1114:20)
	 cljs.core/first (out/cljs/core.cljs:1123:16)
	 cljs$core$ffirst (out/cljs/core.cljs:1634:11)
	 cljs.core.map.cljs$core$IFn$_invoke$arity$2 (out/cljs/core.cljs:4459:30)
	 cljs.core.LazySeq.sval (out/cljs/core.cljs:3217:18)
	 cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (out/cljs/core.cljs:3271:12)
	 cljs.core/seq (out/cljs/core.cljs:1101:25)
	 cljs.core/pr-sequential-writer (out/cljs/core.cljs:9108:20)
	 cljs.core.LazySeq.cljs$core$IPrintWithWriter$_pr_writer$arity$3 (out/cljs/core.cljs:9344:35)




[CLJS-1719] Port destructuring namespaced keys and symbols Created: 29/Jul/16  Updated: 29/Jul/16  Resolved: 29/Jul/16

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

Type: Enhancement Priority: Major
Reporter: António Nuno Monteiro Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1719.patch    
Patch: Code and Test

 Description   

Port CLJ-1919 to Clojurescript



 Comments   
Comment by António Nuno Monteiro [ 29/Jul/16 6:44 PM ]

Attached patch with code and test.

Comment by David Nolen [ 29/Jul/16 8:46 PM ]

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





[CLJS-1653] cljs.spec: keys* causes exception Created: 29/May/16  Updated: 29/Jul/16  Resolved: 29/Jul/16

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

Type: Defect Priority: Major
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1653-2.patch     Text File CLJS-1653.patch    
Patch: Code

 Description   

From https://clojure.org/guides/spec there is a keys* usage in the Entity Maps section. If tried with cljs.spec an exception is thrown:

cljs.user=> (require '[cljs.spec :as s])
nil
cljs.user=> (s/def ::server (s/keys* :req [::id ::host] :opt [::port]))
clojure.lang.ExceptionInfo: No method in multimethod 'parse' for dispatch value: & at line 1 <cljs repl> {:file "<cljs repl>", :line 1, :column 17, :tag :cljs/analysis-error}
	at clojure.core$ex_info.invokeStatic(core.clj:4617)
	at clojure.core$ex_info.invoke(core.clj:4617)
	at cljs.analyzer$error.invokeStatic(analyzer.cljc:580)
	at cljs.analyzer$error.invoke(analyzer.cljc:576)
	at cljs.analyzer$analyze_seq_STAR__wrap.invokeStatic(analyzer.cljc:2420)
	at cljs.analyzer$analyze_seq_STAR__wrap.invoke(analyzer.cljc:2419)
	at cljs.analyzer$analyze_seq.invokeStatic(analyzer.cljc:2442)
	at cljs.analyzer$analyze_seq.invoke(analyzer.cljc:2423)
	at cljs.analyzer$analyze_form.invokeStatic(analyzer.cljc:2555)
	at cljs.analyzer$analyze_form.invoke(analyzer.cljc:2551)
	at cljs.analyzer$analyze_STAR_.invokeStatic(analyzer.cljc:2602)
	at cljs.analyzer$analyze_STAR_.invoke(analyzer.cljc:2593)
	at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:2618)
	at cljs.analyzer$analyze.invoke(analyzer.cljc:2605)
	at cljs.analyzer$analyze_seq.invokeStatic(analyzer.cljc:2443)
	at cljs.analyzer$analyze_seq.invoke(analyzer.cljc:2423)
	at cljs.analyzer$analyze_form.invokeStatic(analyzer.cljc:2555)
	at cljs.analyzer$analyze_form.invoke(analyzer.cljc:2551)
	at cljs.analyzer$analyze_STAR_.invokeStatic(analyzer.cljc:2602)
	at cljs.analyzer$analyze_STAR_.invoke(analyzer.cljc:2593)
	at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:2618)
	at cljs.analyzer$analyze.invoke(analyzer.cljc:2605)
	at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:2613)
	at cljs.analyzer$analyze.invoke(analyzer.cljc:2605)
	at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:2612)
	at cljs.analyzer$analyze.invoke(analyzer.cljc:2605)
	at cljs.analyzer$parse_invoke_STAR_$ana_expr__2106.invoke(analyzer.cljc:2257)
	at clojure.core$map$fn__4785.invoke(core.clj:2646)
	at clojure.lang.LazySeq.sval(LazySeq.java:40)
	at clojure.lang.LazySeq.seq(LazySeq.java:49)
	at clojure.lang.Cons.next(Cons.java:39)
	at clojure.lang.PersistentVector.create(PersistentVector.java:73)
	at clojure.lang.LazilyPersistentVector.create(LazilyPersistentVector.java:44)
	at clojure.core$vec.invokeStatic(core.clj:377)
	at clojure.core$vec.invoke(core.clj:367)
	at cljs.analyzer$parse_invoke_STAR_.invokeStatic(analyzer.cljc:2264)
	at cljs.analyzer$parse_invoke_STAR_.invoke(analyzer.cljc:2235)
	at cljs.analyzer$parse_invoke.invokeStatic(analyzer.cljc:2273)
	at cljs.analyzer$parse_invoke.invoke(analyzer.cljc:2271)
	at cljs.analyzer$analyze_seq_STAR_.invokeStatic(analyzer.cljc:2417)
	at cljs.analyzer$analyze_seq_STAR_.invoke(analyzer.cljc:2414)
	at cljs.analyzer$analyze_seq_STAR__wrap.invokeStatic(analyzer.cljc:2421)
	at cljs.analyzer$analyze_seq_STAR__wrap.invoke(analyzer.cljc:2419)
	at cljs.analyzer$analyze_seq.invokeStatic(analyzer.cljc:2442)
	at cljs.analyzer$analyze_seq.invoke(analyzer.cljc:2423)
	at cljs.analyzer$analyze_form.invokeStatic(analyzer.cljc:2555)
	at cljs.analyzer$analyze_form.invoke(analyzer.cljc:2551)
	at cljs.analyzer$analyze_STAR_.invokeStatic(analyzer.cljc:2602)
	at cljs.analyzer$analyze_STAR_.invoke(analyzer.cljc:2593)
	at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:2618)
	at cljs.analyzer$analyze.invoke(analyzer.cljc:2605)
	at cljs.analyzer$analyze_seq.invokeStatic(analyzer.cljc:2443)
	at cljs.analyzer$analyze_seq.invoke(analyzer.cljc:2423)
	at cljs.analyzer$analyze_form.invokeStatic(analyzer.cljc:2555)
	at cljs.analyzer$analyze_form.invoke(analyzer.cljc:2551)
	at cljs.analyzer$analyze_STAR_.invokeStatic(analyzer.cljc:2602)
	at cljs.analyzer$analyze_STAR_.invoke(analyzer.cljc:2593)
	at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:2618)
	at cljs.analyzer$analyze.invoke(analyzer.cljc:2605)
	at cljs.repl$evaluate_form.invokeStatic(repl.cljc:450)
	at cljs.repl$evaluate_form.invoke(repl.cljc:440)
	at cljs.repl$eval_cljs.invokeStatic(repl.cljc:570)
	at cljs.repl$eval_cljs.invoke(repl.cljc:563)
	at cljs.repl$repl_STAR_$read_eval_print__6148.invoke(repl.cljc:875)
	at cljs.repl$repl_STAR_$fn__6154$fn__6163.invoke(repl.cljc:914)
	at cljs.repl$repl_STAR_$fn__6154.invoke(repl.cljc:913)
	at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1154)
	at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1145)
	at cljs.repl$repl_STAR_.invokeStatic(repl.cljc:877)
	at cljs.repl$repl_STAR_.invoke(repl.cljc:761)
	at cljs.repl$repl.invokeStatic(repl.cljc:995)
	at cljs.repl$repl.doInvoke(repl.cljc:925)
	at clojure.lang.RestFn.invoke(RestFn.java:410)
	at user$eval6335.invokeStatic(NO_SOURCE_FILE:3)
	at user$eval6335.invoke(NO_SOURCE_FILE:3)
	at clojure.lang.Compiler.eval(Compiler.java:6927)
	at clojure.lang.Compiler.eval(Compiler.java:6890)
	at clojure.core$eval.invokeStatic(core.clj:3105)
	at clojure.main$eval_opt.invokeStatic(main.clj:288)
	at clojure.main$eval_opt.invoke(main.clj:282)
	at clojure.main$initialize.invokeStatic(main.clj:308)
	at clojure.main$null_opt.invokeStatic(main.clj:342)
	at clojure.main$null_opt.invoke(main.clj:339)
	at clojure.main$main.invokeStatic(main.clj:421)
	at clojure.main$main.doInvoke(main.clj:384)
	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)
Caused by: java.lang.IllegalArgumentException: No method in multimethod 'parse' for dispatch value: &
	at clojure.lang.MultiFn.getFn(MultiFn.java:156)
	at clojure.lang.MultiFn.invoke(MultiFn.java:251)
	at cljs.analyzer$analyze_seq_STAR_.invokeStatic(analyzer.cljc:2416)
	at cljs.analyzer$analyze_seq_STAR_.invoke(analyzer.cljc:2414)
	at cljs.analyzer$analyze_seq_STAR__wrap.invokeStatic(analyzer.cljc:2421)
	... 85 more


 Comments   
Comment by Mike Fikes [ 30/May/16 10:55 AM ]

The attached patch works around the issue by qualifying the reference to cljs.spec/&.

With it, the example in the docstring works:

(s/conform (s/cat :i1 integer? :m (s/keys* :req-un [::a ::c]) :i2 integer?) [42 :a 1 :c 2 :d 4 99])
{:i1 42, :m {:a 1, :c 2, :d 4}, :i2 99}

(There is probably a more correct solution that probably involves changing the analyzer, which would lead to users being able to refer & and use it as (& ...), but this patch would get us by for now if desired.)

Comment by Mike Fikes [ 27/Jul/16 10:05 AM ]

Original patch no longer applies; attaching CLJS-1653-2.patch.

Comment by David Nolen [ 29/Jul/16 3:13 PM ]

fixed https://github.com/clojure/clojurescript/commit/5a78c9fb881f08b1f9578f9cd9dd265bbdd5c720





[CLJS-1700] Support clojure.* aliasing when not in vector Created: 03/Jul/16  Updated: 29/Jul/16  Resolved: 29/Jul/16

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

Type: Enhancement Priority: Major
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1700.patch    
Patch: Code and Test

 Description   

While this works:

(ns foo.core
  (:require [clojure.test]))

this does not:

(ns foo.core
  (:require clojure.test))


 Comments   
Comment by António Nuno Monteiro [ 27/Jul/16 10:59 AM ]

Attached patch with fix and test.

Comment by David Nolen [ 29/Jul/16 3:07 PM ]

fixed https://github.com/clojure/clojurescript/commit/689f6d3197a710daf55aa234b81e4468afd9ff9e





[CLJS-1717] remove unnecessary map from equiv-map Created: 29/Jul/16  Updated: 29/Jul/16  Resolved: 29/Jul/16

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

Type: Enhancement Priority: Trivial
Reporter: Thomas Mulvaney Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File CLJS-1717.patch    
Patch: Code

 Description   

Simplifies code and removes a sequence allocation speeding up equiv-map.



 Comments   
Comment by David Nolen [ 29/Jul/16 3:05 PM ]

fixed https://github.com/clojure/clojurescript/commit/82dce0b1ed322af25e1ebe2cf91e3afec9e249ec





[CLJS-1716] No longer possible to use same alias for :require-macros and :require Created: 27/Jul/16  Updated: 29/Jul/16  Resolved: 29/Jul/16

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

Type: Defect Priority: Minor
Reporter: Juho Teperi Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None
Environment:

1.9.146 / 8643c55


Attachments: Text File CLJS-1716.patch    
Patch: Code

 Description   

It was possible possible to use same alias for :require-macros and :require:

(ns hello-world.core
  (:require-macros [cljs.core.async.macros :as a])
  (:require [cljs.core.async :as a]))

(a/go
  (a/<! (a/timeout 1000))
  (println "hello"))

This works with 1.9.89 but on 1.9.146 this causes a warning:

WARNING: Use of undeclared Var cljs.core.async/go at line 5 src/hello_world/core.cljs

According to anmonteiro at Slack, this is caused by commit https://github.com/clojure/clojurescript/commit/41a62bfd916208d30bf621aefba56c5dce031ce5

Based on discussion at Slack, this feature is non intentional and fixing this is low-priority.

Minimal test project is available at https://github.com/Deraen/problems/tree/cljs-1692-same-alias
This still uses lein to retrieve deps as using core.async with cljs.jar proved complicated.



 Comments   
Comment by António Nuno Monteiro [ 27/Jul/16 6:27 PM ]

Attached patch with fix

Comment by Juho Teperi [ 28/Jul/16 4:40 AM ]

I can confirm that the patch works.

Comment by David Nolen [ 29/Jul/16 3:02 PM ]

fixed https://github.com/clojure/clojurescript/commit/82a2a293e7b0b30f78399f997ec26d808473b8e2





[CLJS-1718] Foreign lib files should be placed in a location that matches their namespace Created: 29/Jul/16  Updated: 29/Jul/16

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

Type: Defect Priority: Minor
Reporter: António Nuno Monteiro Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Affects master



 Description   

Using several foreign libs with the same file name ends up just including one of them, as the files are placed at the root of the `:output-dir`.

A solution for this would be placing those files in a location that matches their `:provides` namespace.






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

Status: Closed
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: Completed 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


 Comments   
Comment by António Nuno Monteiro [ 29/Jul/16 6:42 AM ]

Can no longer repro

$ java -jar cljs.jar -m cljs.repl.node
ClojureScript Node.js REPL server listening on 52864
To quit, type: :cljs/quit
cljs.user=> *clojurescript-version*
"1.9.89"
cljs.user=> (doc ..)
-------------------------
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.user=>
Comment by David Nolen [ 29/Jul/16 7:41 AM ]

fixed





[CLJS-1241] Add cljs.core/boolean? predicate Created: 03/May/15  Updated: 29/Jul/16  Resolved: 29/Jul/16

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

Type: Enhancement Priority: Minor
Reporter: Brandon Bloom Assignee: Unassigned
Resolution: Completed Votes: 2
Labels: patch

Attachments: Text File CLJS-1241_v01.patch    
Patch: Code and Test

 Description   

I'm constantly re-implementing this predicate...

It's also important for clj/cljs compatibility.



 Comments   
Comment by Brandon Bloom [ 03/May/15 2:32 PM ]

See also: http://dev.clojure.org/jira/browse/CLJ-1719

Comment by Mike Fikes [ 03/May/15 2:52 PM ]

I tried this patch and it works correctly for me.

The docstring uses "typeof". Perhaps "type of" was intended?

cljs.user=> (doc boolean?)
-------------------------
cljs.core/boolean?
([x])
  Returns true if the typeof x is boolean, false otherwise.

nil
Comment by Brandon Bloom [ 03/May/15 7:41 PM ]

I did mean "typeof", which is a javascript-ism. A better doc string may be less javascript-specific...

Comment by Mike Fikes [ 31/Jan/16 3:17 PM ]

Patch CLJS-1241_v01.patch no longer applies on master.

Comment by Brandon Bloom [ 31/Jan/16 7:13 PM ]

Not going to bother updating patch until there is movement on http://dev.clojure.org/jira/browse/CLJ-1719

Comment by António Nuno Monteiro [ 29/Jul/16 7:06 AM ]

This has been implemented in Clojurescript as of https://github.com/clojure/clojurescript/commit/73ab8ff8f4610a6f11cf64cc09e7173dcada5dc0

Comment by David Nolen [ 29/Jul/16 7:41 AM ]

Added to Clojure 1.9.0 alphas and ClojureScript 1.9.X





[CLJS-1683] js->clj passes opts incorrectly Created: 15/Jun/16  Updated: 29/Jul/16  Resolved: 29/Jul/16

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

Type: Defect Priority: Trivial
Reporter: Oliver George Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None


 Description   

This seems be a bug but nil-punning makes it work.

A good reason for fixing is that inspecting the code leads you to think the calling convention is different.

([x] (js->clj x {:keywordize-keys false}))

should be this (remove map)

([x] (js->clj x :keywordize-keys false))

in

(defn js->clj
  "Recursively transforms JavaScript arrays into ClojureScript
  vectors, and JavaScript objects into ClojureScript maps.  With
  option ':keywordize-keys true' will convert object fields from
  strings to keywords."
  ([x] (js->clj x {:keywordize-keys false}))
  ([x & opts]
    (let [{:keys [keywordize-keys]} opts
          keyfn (if keywordize-keys keyword str)
          f (fn thisfn [x]

So calling (js->clj x) becomes (js->clj x {:keywordize-keys false}) which means opts is [{:keywordize-keys false}] but is destructured as a map.

Result is keywordize-keys is nil rather than false. No drama.

(It got me because I was unsure how to call with :keywordize-keys set. I looked at that code, swapped false with true and was confused when it didn't work. (keywordized-keys was still nil.)



 Comments   
Comment by António Nuno Monteiro [ 29/Jul/16 7:24 AM ]

This has been fixed in https://github.com/clojure/clojurescript/commit/0fcbef2bf6be543ce72de4797701fdd55b332922

Comment by David Nolen [ 29/Jul/16 7:40 AM ]

fixed





[CLJS-1681] Make instrument-all / unstrument-all return nil Created: 11/Jun/16  Updated: 27/Jul/16  Resolved: 27/Jul/16

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

Type: Enhancement Priority: Minor
Reporter: Mike Fikes Assignee: David Nolen
Resolution: Not Reproducible Votes: 0
Labels: None

Attachments: Text File CLJS-1681.patch    
Patch: Code and Test

 Description   

In Clojure, instrument-all and unstrument-all return nil, but in ClojureScript will return the last var instrumented / unstrumented by the resulting macroexpansion.



 Comments   
Comment by Mike Fikes [ 11/Jun/16 6:01 PM ]

The attached CLJS-1681 broadens the scope a little and also takes care of instrument-ns / unstrument-ns.

Comment by Mike Fikes [ 27/Jul/16 9:29 AM ]

The attached patch no longer applies (not just mechanically but also because the functions involved have evolved while tracking Clojure).





[CLJS-1297] defrecord does not emit IKVReduce protocol Created: 03/Jun/15  Updated: 27/Jul/16

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

Type: Defect Priority: Major
Reporter: Daniel Skarda Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: newbie

Attachments: Text File CLJS-1297-19-July-2015.patch    

 Description   

Records are maps and in Clojure they support reduce-kv (IKVReduce protocol).
This is not true in ClojureScript:

(defrecord Foobar [x y])
 (reduce-kv assoc {} (Foobar. 1 2))

Fails wit Error: No protocol method IKVReduce.-kv-reduce defined for type : [object Object]



 Comments   
Comment by David Nolen [ 03/Jun/15 7:25 PM ]

Just seems like an oversight. Patch welcome, this one is a relatively easy one.

Comment by Daniel Skarda [ 04/Jun/15 2:53 AM ]

OK

I checked Clojure implementation. Records do not implement any reduce protocol on their own. For IKVReduce records use default implementation using reduce and destructuring. Is this approach OK?

Recently Alex Miller implemented many optimizations of reduce protocols in Clojure. Eg range returns an object which implements IReduce protocol so reduce (and transducers in general) can take advantage of it. Any plans for such optimizations in ClojureScript?

;;clojure/src/clj/clojure/core.clj:6523
;;slow path default
clojure.lang.IPersistentMap
(kv-reduce 
  [amap f init]
  (reduce (fn [ret [k v]] (f ret k v)) init amap))
Comment by David Nolen [ 04/Jun/15 9:05 AM ]

Going with the Clojure implementation is fine. Yes all of the optimizations in 1.7.0 are on the table for ClojureScript but these are separate issues from this one.

Comment by Samuel Miller [ 16/Jul/15 10:39 PM ]

Mind if I take this as my first cljs bug? Poking around quickly I think I know what needs to happen.

Comment by David Nolen [ 17/Jul/15 5:21 AM ]

Sure! Have you submitted your CA yet?

Comment by Samuel Miller