<< Back to previous view

[CLJS-3021] Circular dependency detected when referring cljs.js and using :optimize-constants true Created: 16/Dec/18  Updated: 16/Dec/18

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

Type: Defect Priority: Minor
Reporter: Michiel Borkent Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Given the following project:

;; file src/foo.cljs
(ns foo
  (:require [cljs.js :as cljs]))

(defn -main []
  (enable-console-print!)
  (println "hello"))
;; file deps.edn
{:deps {org.clojure/clojure {:mvn/version "1.10.0-RC5"}
        org.clojure/clojurescript {:mvn/version "1.10.439"}
        }
 :aliases {:build-simple {:main-opts ["-m" "cljs.main" "-O" "simple" "-co" "{:pretty-print,false,:optimize-constants,true,:static-fns,true}" "-d" "out" "-c" "foo"]}}}

the following stacktrace is seen:

Exception in thread "main" clojure.lang.ExceptionInfo: failed compiling file:out/cljs/core.cljc {:file #object[java.io.File 0x7e7f3cfd "out/cljs/core.cljc"]}
...
Caused by: clojure.lang.ExceptionInfo: Assert failed: Circular dependency detected, cljs.core -> cljs.core
...
Caused by: java.lang.AssertionError: Assert failed: Circular dependency detected, cljs.core -> cljs.core
...

This exception does not happen when :optimize-constants is set to false or when cljs.js is not required.

This setting was proposed in the following guide on the CLJS website: https://clojurescript.org/guides/self-hosting






[CLJS-3020] cljs.main: Incorrect documentation for the --compile flag Created: 16/Dec/18  Updated: 17/Dec/18

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

Type: Defect Priority: Trivial
Reporter: Anton Fonarev Assignee: Anton Fonarev
Resolution: Unresolved Votes: 0
Labels: None

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

 Description   

The current documentation for the --c flag mentions the nonexistent --server flag:

   -c, --compile [ns]         Run a compile. If optional namespace specified, 
                              use as the main entry point. If --repl follows, 
                              will launch a REPL after the compile completes. 
                              If --server follows, will start a web server that 
                              serves the current directory after the compile 
                              completes.


 Comments   
Comment by Mike Fikes [ 17/Dec/18 9:26 AM ]

Thanks for the patch Anton.

You'll need to sign the CA if you haven't yet. See https://clojurescript.org/community/contributing

Additionally, the patch needs to be formatted per https://clojurescript.org/community/patches

Comment by Anton Fonarev [ 17/Dec/18 3:35 PM ]

Mike, done!





[CLJS-3019] Error->map should produce qualified symbols for :type Created: 15/Dec/18  Updated: 15/Dec/18

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

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

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

 Description   

In the following

cljs.user=> (cljs.repl/Error->map (ex-info "" {}))
{:via [{:type ExceptionInfo, :message "", :data {}}], :trace nil, :cause "", :data {}}

the ExceptionInfo value should be cljs.core/ExceptionInfo.



 Comments   
Comment by Mike Fikes [ 15/Dec/18 5:45 PM ]

CLJS-3019.patch simply revises the quote to be syntax-quote and adds a test.

Comment by Mike Fikes [ 15/Dec/18 7:03 PM ]

CLJS-3019.patch passes CI





[CLJS-3018] Preserve type of function with metadata Created: 15/Dec/18  Updated: 15/Dec/18

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

Type: Enhancement Priority: Minor
Reporter: William Acton Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: cljs
Environment:

N/A


Attachments: Text File CLJS-3018.patch    

 Description   

Currently, IWithMeta is implemented for functions by wrapping the function in a MetaFn type.

However, this breaks certain expectations about the typeof of the meta-fied value:

(defn Foo [_] "bar")

(goog/typeOf Foo)
;; => "function"

(goog/typeOf (with-meta Foo {:bar "baz"}))
;; => "object"

The primary case when this is not ideal is when interoping with JS code that does checks using typeof, like React does:

(react-is/isValidElementType Foo)
;; => true

(react-is/isValidElementType (with-meta Foo {:bar "baz"}))
;; => false

Ideally, with-meta would preserve the typeof value when possible.



 Comments   
Comment by William Acton [ 15/Dec/18 4:10 PM ]

There's a separate issue about MetaFn's and varargs, https://dev.clojure.org/jira/browse/CLJS-2446, whose proposed implementation also solves this particular edge case.

Comment by William Acton [ 15/Dec/18 7:00 PM ]

Attached patch:

  • replaces `MetaFn` type with `meta-fn` helper that creates new fn
    with IMeta specify!'d on it.
  • Also fixes CLJS-2446: with-meta doesn't work for variable arguments functions
  • Adds tests for metadata and fns




[CLJS-3017] Error->map: Map js/InternalError and js/TypeError Created: 15/Dec/18  Updated: 15/Dec/18

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

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

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

 Description   

This mapping is missing js/InternalError and js/TypeError.

https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/repl.cljs#L75



 Comments   
Comment by Mike Fikes [ 15/Dec/18 5:43 PM ]

CLJS-3017.patch revises the mapping to be open, making use of the name property.

Comment by Mike Fikes [ 15/Dec/18 7:02 PM ]

CLJS-3017.patch passes in CI





[CLJS-3016] Enable cljs.core.specs.alpha Created: 15/Dec/18  Updated: 15/Dec/18

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

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


 Description   

Enable cljs.core.specs.alpha at least at the REPL and ideally for compilation.

Rationale: For alignment with Clojure.

Note: The cljs.core.specs.alpha namespace was ported around a year ago, CLJS-2413 and has shipped since 1.10.63 as an opt-in feature.

Enabling this could slow down compilation (it would be worth checking).

Enabling this could cause certain code that compiles now to no longer compile if they contain code that doesn't pass the specs (similar to what happened in Clojure).






[CLJS-3015] cljs.repl/ex-triage uses ns-keys destructuring with non-simple symbols Created: 15/Dec/18  Updated: 15/Dec/18

Status: In Progress
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

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

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

 Description   

There is a bit of restructuring in cljs.repl/ex-triage that fails the :cljs.core.specs.alpha/ns-keys spec:

{::spec/keys [:problems :fn :cljs.spec.test.alpha/caller]} data

https://github.com/clojure/clojurescript/blob/6ccb629e365f46a9516e4defeced652cce9d4d35/src/main/cljs/cljs/repl.cljs#L121

Repro:

$ clj -Sdeps '{:deps {org.clojure/clojurescript {:git/url "https://github.com/clojure/clojurescript" :sha "6ccb629e365f46a9516e4defeced652cce9d4d35"}}}' -m cljs.main

cljs.user=> cljs.user=>
cljs.user=> (require '[cljs.core.specs.alpha :as spec])
nil
cljs.user=> (let [{::spec/keys [:problems :fn :cljs.spec.test.alpha/caller]} nil])
Syntax error macroexpanding cljs.core/let at (<cljs repl>:1:1).
:cljs.core.specs.alpha/keys - failed: simple-symbol? at: [:bindings :form :map-destructure :map-binding 0 :local-symbol] spec: :cljs.core.specs.alpha/local-name
:cljs.core.specs.alpha/keys - failed: vector? at: [:bindings :form :map-destructure :map-binding 0 :seq-destructure] spec: :cljs.core.specs.alpha/seq-binding-form
:cljs.core.specs.alpha/keys - failed: map? at: [:bindings :form :map-destructure :map-binding 0 :map-destructure] spec: :cljs.core.specs.alpha/map-bindings
:cljs.core.specs.alpha/keys - failed: map? at: [:bindings :form :map-destructure :map-binding 0 :map-destructure] spec: :cljs.core.specs.alpha/map-special-binding
:problems - failed: simple-symbol? at: [:bindings :form :map-destructure :qualified-keys-or-syms 1] spec: :cljs.core.specs.alpha/ns-keys
:fn - failed: simple-symbol? at: [:bindings :form :map-destructure :qualified-keys-or-syms 1] spec: :cljs.core.specs.alpha/ns-keys
:cljs.spec.test.alpha/caller - failed: simple-symbol? at: [:bindings :form :map-destructure :qualified-keys-or-syms 1] spec: :cljs.core.specs.alpha/ns-keys
:cljs.core.specs.alpha/keys - failed: #{:as :or :syms :keys :strs} at: [:bindings :form :map-destructure :special-binding 0] spec: :cljs.core.specs.alpha/map-bindings
#:cljs.core.specs.alpha{:keys [:problems :fn :cljs.spec.test.alpha/caller]} - failed: simple-symbol? at: [:bindings :form :local-symbol] spec: :cljs.core.specs.alpha/local-name
#:cljs.core.specs.alpha{:keys [:problems :fn :cljs.spec.test.alpha/caller]} - failed: vector? at: [:bindings :form :seq-destructure] spec: :cljs.core.specs.alpha/seq-binding-form


 Comments   
Comment by Mike Fikes [ 15/Dec/18 12:45 PM ]

CLJS-3015.patch passes CI





[CLJS-3014] Promote Error->map to be a core fn Created: 15/Dec/18  Updated: 15/Dec/18

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

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


 Description   

cljs.repl/Error->map is an imitation of clojure.core/Throwable->map.

It could be cleaned up and promoted to instead be cljs.core/Error->map.

If this were done, a side decision could be pondered and taken on whether it should be named cljs.core/Throwable->map. (You can see arguments both for and against this.)






[CLJS-3013] Use "REPL" to indicate source Created: 14/Dec/18  Updated: 14/Dec/18

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

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


 Description   

With the enhanced error printing, you can see that the source is often indicated using a <cljs repl> indicator.

With the same feature in Clojure the source is REPL.

Compare:

ClojureScript:

cljs.user=> (ffirst 1)
Execution error (Error) at (<cljs repl>:1).
1 is not ISeqable

Clojure:

user=> (ffirst 1)
Execution error (IllegalArgumentException) at user/eval1 (REPL:1).
Don't know how to create ISeq from: java.lang.Long

This enhancement asks that source simply be referred to as REPL as is done in Clojure.






[CLJS-3012] Eliminate empty line after enhanced execution phase error printing Created: 14/Dec/18  Updated: 14/Dec/18

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-3012.patch    
Patch: Code

 Description   

There is not normally an empty line after an enhanced error printout. See Clojure, and for example, see this example in ClojureScript:

cljs.user=> (require '[cljs.core.specs.alpha])
nil
cljs.user=> (let [1])
Syntax error macroexpanding cljs.core/let at (<cljs repl>:1:1).
[1] - failed: even-number-of-forms? at: [:bindings] spec: :cljs.core.specs.alpha/bindings
cljs.user=>

But, with CLJS-2945 and CLJS-3011 you can see that there is an extra blank line for :clojure.error.phase :execution printing.

The attached patch eliminates this extra blank line, making things consistent within ClojureScript and also consistent with Clojure. Here is an example with the patch:

cljs.user=> (ffirst 1)
Execution error (Error) at (<cljs repl>:1).
1 is not ISeqable
cljs.user=>

and without the patch you would see:

cljs.user=> (ffirst 1)
Execution error (Error) at (<cljs repl>:1).
1 is not ISeqable

cljs.user=>

A slight difficulty is that the enhanced error printing strings have newlines at the end. See for example:

https://github.com/clojure/clojurescript/blob/6ccb629e365f46a9516e4defeced652cce9d4d35/src/main/cljs/cljs/repl.cljs#L188

The display error code is used for other errors, so the fix taken in this patch is to enforce uniformity by employing trimr.



 Comments   
Comment by Mike Fikes [ 14/Dec/18 9:28 PM ]

CLJS-3012.patch passes CI





[CLJS-3011] Port improved runtime exception printing to non-Node REPLs Created: 14/Dec/18  Updated: 14/Dec/18

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

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

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

 Description   

With CLJS-2945, improved exception printing was pushed down into the runtime, but only for the Node JS REPL. In particular this line hooks things up to cljs.repl/error->str:

https://github.com/clojure/clojurescript/blob/59997385d85e7e1af1559d599eb51fdb1d7e93b1/src/main/clojure/cljs/repl/node_repl.js#L89

A similar change would be needed for the browser, Nashorn, and other shipping REPLs.



 Comments   
Comment by Mike Fikes [ 14/Dec/18 8:12 PM ]

CLJS-3011.patch adds support for the browser REPL, Nashorn, Rhino, and GraalJS.

The main theme in the patch is to no longer pass back exception stack traces when evaluation errors occur, but to instead feed the resulting error object to the improved exception printing functions Error->map, ex-triage, ex-str. This often leads to simpler code, involving deleting bits related to stack traces. Note that this doesn't mean you can no longer see stacktraces: These are still visible when you do a (pst), which has its own separate way of getting the stack.

Below is manual test output for each environment, including Node for comparison. It shows the spec error reporting from CLJS-2945 along with doing a (pst) to show that you can obtain a stack trace, along with error reporting for (ffirst 1) and a (pst) for that as well.

The only problematic case was Rhino, which, perhaps owing to its odd handling of *e, couldn't quite show things, so I had it fall back to the Clojure error reporting in that case.

Node:

$ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.493"}  org.clojure/test.check {:mvn/version "0.10.0-alpha3"}}}' -m cljs.main -re node -d node-out -r
ClojureScript 1.10.493
cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (require '[clojure.spec.test.alpha :as st])
nil
cljs.user=> (defn foo [x] (inc x))
#'cljs.user/foo
cljs.user=> (s/fdef foo :args (s/cat :n int?))
cljs.user/foo
cljs.user=> (st/instrument)
[cljs.user/foo]
cljs.user=> (foo "A")
Execution error - invalid arguments to cljs.user/foo at (<cljs repl>:1).
"A" - failed: int? at: [:n]

cljs.user=> (pst)
repl:13
throw e__6692__auto__;
^

Error: Call to #'cljs.user/foo did not conform to spec.
    at new cljs$core$ExceptionInfo (/private/tmp/CLJS-3011/node-out/cljs/core.js:37039:10)
    at Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (/private/tmp/CLJS-3011/node-out/cljs/core.js:37100:9)
    at Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$2 (/private/tmp/CLJS-3011/node-out/cljs/core.js:37096:26)
    at cljs$core$ex_info (/private/tmp/CLJS-3011/node-out/cljs/core.js:37082:26)
    at /private/tmp/CLJS-3011/node-out/cljs/spec/test/alpha.js:134:25
    at /private/tmp/CLJS-3011/node-out/cljs/spec/test/alpha.js:164:22
    at G__1880__delegate (/private/tmp/CLJS-3011/node-out/cljs/spec/test/alpha.js:174:25)
    at G__1880 (/private/tmp/CLJS-3011/node-out/cljs/spec/test/alpha.js:194:26)
    at repl:1:103
    at repl:9:3
nil
cljs.user=> (ffirst 1)
Execution error (Error) at (<cljs repl>:1).
1 is not ISeqable

cljs.user=> (pst)
repl:13
throw e__6692__auto__;
^

Error: 1 is not ISeqable
    at Object.cljs$core$seq [as seq] (/private/tmp/CLJS-3011/node-out/cljs/core.js:4442:8)
    at Object.cljs$core$first [as first] (/private/tmp/CLJS-3011/node-out/cljs/core.js:4461:19)
    at cljs$core$ffirst (/private/tmp/CLJS-3011/node-out/cljs/core.js:5915:34)
    at repl:1:106
    at repl:9:3
    at repl:14:4
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at Object.runInThisContext (vm.js:139:38)
    at Domain.<anonymous> ([stdin]:76:38)
    at Domain.run (domain.js:242:14)
nil

Browser:

$ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.493"}  org.clojure/test.check {:mvn/version "0.10.0-alpha3"}}}' -m cljs.main -re browser -d browser-out -r
ClojureScript 1.10.493
cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (require '[clojure.spec.test.alpha :as st])
nil
cljs.user=> (defn foo [x] (inc x))
#'cljs.user/foo
cljs.user=> (s/fdef foo :args (s/cat :n int?))
cljs.user/foo
cljs.user=> (st/instrument)
[cljs.user/foo]
cljs.user=> (foo "A")
Execution error - invalid arguments to cljs.user/foo at (<cljs repl>:1).
"A" - failed: int? at: [:n]

cljs.user=> (pst)
#error {:message "Call to #'cljs.user/foo did not conform to spec.", :data #:cljs.spec.alpha{:problems [{:path [:n], :pred cljs.core/int?, :val "A", :via [], :in [0]}], :spec #object[cljs.spec.alpha.t_cljs$spec$alpha1431], :value ("A"), :fn cljs.user/foo, :args ("A"), :failure :instrument}}
	 cljs.core/ExceptionInfo (browser-out/cljs/core.cljs:11304:11)
	 cljs$core$IFn$_invoke$arity$3 (browser-out/cljs/core.cljs:11336:5)
	 cljs$core$IFn$_invoke$arity$2 (browser-out/cljs/core.cljs:11334:16)
	 cljs$core$ex_info (browser-out/cljs/core.cljs:11331:1)
	 G__4950__delegate (browser-out/cljs/spec/test/alpha.cljs:121:22)
	 G__4950 (browser-out/cljs/spec/test/alpha.cljs:118:22)
nil
cljs.user=> (ffirst 1)
Execution error (Error) at (<cljs repl>:1).
1 is not ISeqable

cljs.user=> (pst)
Error: 1 is not ISeqable
	 cljs.core/seq (browser-out/cljs/core.cljs:1226:20)
	 cljs.core/first (browser-out/cljs/core.cljs:1235:16)
	 cljs$core$ffirst (browser-out/cljs/core.cljs:1751:11)
nil

Nashorn:

$ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.493"}  org.clojure/test.check {:mvn/version "0.10.0-alpha3"}}}' -m cljs.main -re nashorn -d nashorn-out -r
ClojureScript 1.10.493
cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (require '[clojure.spec.test.alpha :as st])
nil
cljs.user=> (defn foo [x] (inc x))
#'cljs.user/foo
cljs.user=> (s/fdef foo :args (s/cat :n int?))
cljs.user/foo
cljs.user=> (st/instrument)
[cljs.user/foo]
cljs.user=> (foo "A")
Execution error - invalid arguments to cljs.user/foo at (<cljs repl>:1).
"A" - failed: int? at: [:n]

cljs.user=> (pst)
#error {:message "Call to #'cljs.user/foo did not conform to spec.", :data #:cljs.spec.alpha{:problems [{:path [:n], :pred cljs.core/int?, :val "A", :via [], :in [0]}], :spec #object[cljs.spec.alpha.t_cljs$spec$alpha4058], :value ("A"), :fn cljs.user/foo, :args ("A"), :failure :instrument}}
	 cljs$core$ExceptionInfo (nashorn-out/cljs/core.cljs:11304:3)
	 cljs$core$IFn$_invoke$arity$3 (nashorn-out/cljs/core.cljs:11336:5)
	 cljs$core$IFn$_invoke$arity$2 (nashorn-out/cljs/core.cljs:11334:15)
	 cljs$core$ex_info (nashorn-out/cljs/core.cljs:11331:1)
	 <anonymous> (nashorn-out/cljs/spec/test/alpha.cljs:105:26)
	 <anonymous> (nashorn-out/cljs/spec/test/alpha.cljs:116:20)
	 G__5520__delegate (nashorn-out/cljs/spec/test/alpha.cljs:120:19)
	 G__5520 (nashorn-out/cljs/spec/test/alpha.cljs:118:22)
	 (<NO_SOURCE_FILE> <eval>:1:0)
	 (<NO_SOURCE_FILE> <eval>:1:0)
	 (<NO_SOURCE_FILE> <eval>:1:0)
nil
cljs.user=> (ffirst 1)
Execution error (Error) at (<cljs repl>:1).
1 is not ISeqable

cljs.user=> (pst)
Error: 1 is not ISeqable
	 cljs$core$seq (nashorn-out/cljs/core.cljs:1226:13)
	 cljs$core$first (nashorn-out/cljs/core.cljs:1235:7)
	 cljs$core$ffirst (nashorn-out/cljs/core.cljs:1751:3)
	 (<NO_SOURCE_FILE> <eval>:1:0)
	 (<NO_SOURCE_FILE> <eval>:1:0)
	 (<NO_SOURCE_FILE> <eval>:1:0)
nil

Rhino:

$ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.493"}  org.clojure/test.check {:mvn/version "0.10.0-alpha3"}}}' -m cljs.main -re rhino -d rhino-out -r
ClojureScript 1.10.493
cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (require '[clojure.spec.test.alpha :as st])
nil
cljs.user=> (defn foo [x] (inc x))
#'cljs.user/foo
cljs.user=> (s/fdef foo :args (s/cat :n int?))
cljs.user/foo
cljs.user=> (st/instrument)
[cljs.user/foo]
cljs.user=> (foo "A")
Execution error (JavaScriptException) at org.mozilla.javascript.Interpreter/interpretLoop (Interpreter.java:1018).
#error {:message "Call to #'cljs.user/foo did not conform to spec.", :data #:cljs.spec.alpha{:problems [{:path [:n], :pred cljs.core/int?, :val "A", :via [], :in [0]}], :spec #object[cljs.spec.alpha.t_cljs$spec$alpha1431], :value ("A"), :fn cljs.user/foo, :args ("A"), :failure :instrument}} (rhino-out/goog/../cljs/spec/test/alpha.js#134)

cljs.user=> (pst)
org.mozilla.javascript.JavaScriptException: #error {:message "Call to #'cljs.user/foo did not conform to spec.", :data #:cljs.spec.alpha{:problems [{:path [:n], :pred cljs.core/int?, :val "A", :via [], :in [0]}], :spec #object[cljs.spec.alpha.t_cljs$spec$alpha1431], :value ("A"), :fn cljs.user/foo, :args ("A"), :failure :instrument}} (rhino-out/goog/../cljs/spec/test/alpha.js#134)
	 (rhino-out/cljs/spec/test/alpha.cljs:105:26)
	 (rhino-out/cljs/spec/test/alpha.cljs:116:20)
	 (rhino-out/cljs/spec/test/alpha.cljs:120:19)
	 (rhino-out/cljs/spec/test/alpha.cljs:118:22)
	 (<NO_SOURCE_FILE> <cljs repl>:1:0)
	 (<NO_SOURCE_FILE> <cljs repl>:1:0)
nil
cljs.user=> (ffirst 1)
Execution error (JavaScriptException) at org.mozilla.javascript.Interpreter/interpretLoop (Interpreter.java:1018).
Error: 1 is not ISeqable (rhino-out/goog/../cljs/core.js#4442)

cljs.user=> (pst)
org.mozilla.javascript.JavaScriptException: Error: 1 is not ISeqable (rhino-out/goog/../cljs/core.js#4442)
	 cljs$core$seq (rhino-out/cljs/core.cljs:1226:13)
	 cljs$core$first (rhino-out/cljs/core.cljs:1235:7)
	 cljs$core$ffirst (rhino-out/cljs/core.cljs:1751:3)
	 (<NO_SOURCE_FILE> <cljs repl>:1:0)
	 (<NO_SOURCE_FILE> <cljs repl>:1:0)
nil

GraalJS:

$ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.493"}  org.clojure/test.check {:mvn/version "0.10.0-alpha3"}}}' -m cljs.main -re graaljs -d graaljs-out -r
ClojureScript 1.10.493
cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (require '[clojure.spec.test.alpha :as st])
nil
cljs.user=> (defn foo [x] (inc x))
#'cljs.user/foo
cljs.user=> (s/fdef foo :args (s/cat :n int?))
cljs.user/foo
cljs.user=> (st/instrument)
[cljs.user/foo]
cljs.user=> (foo "A")
Execution error - invalid arguments to cljs.user/foo at (<cljs repl>:1).
"A" - failed: int? at: [:n]

cljs.user=> (pst)
#error {:message "Call to #'cljs.user/foo did not conform to spec.", :data #:cljs.spec.alpha{:problems [{:path [:n], :pred cljs.core/int?, :val "A", :via [], :in [0]}], :spec #object[cljs.spec.alpha.t_cljs$spec$alpha4075], :value ("A"), :fn cljs.user/foo, :args ("A"), :failure :instrument}}
    at cljs$core$ExceptionInfo.cljs$core$ExceptionInfo (core.js:37039:10)
    at Function.cljs$core$IFn$_invoke$arity$3 (core.js:37100:9)
    at Function.cljs$core$IFn$_invoke$arity$2 (core.js:37096:26)
    at cljs$core$ex_info (core.js:37082:26)
    at alpha.js:134:25
    at alpha.js:164:22
    at G__5537__delegate (alpha.js:174:25)
    at G__5537 (alpha.js:194:26)
    at <eval>:1:103
    at <eval>:1:52
nil
cljs.user=> (ffirst 1)
Execution error (Error) at (<cljs repl>:1).
1 is not ISeqable

cljs.user=> (pst)
Error: 1 is not ISeqable
    at Object.cljs$core$seq (core.js:4442:8)
    at Object.cljs$core$first (core.js:4461:19)
    at cljs$core$ffirst (core.js:5915:34)
    at <eval>:1:106
    at <eval>:1:52
    at <eval>:1:1
nil
Comment by Mike Fikes [ 14/Dec/18 8:30 PM ]

CLJS-3011.patch passes CI





[CLJS-3010] Datafy does not properly check for whether the datafied value supports metadata Created: 13/Dec/18  Updated: 14/Dec/18  Resolved: 14/Dec/18

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

Type: Defect Priority: Blocker
Reporter: William Acton Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: bug
Environment:

N/A


Attachments: Text File CLJS-3010.patch    
Approval: Accepted

 Description   

I think this line is supposed to check if we can add meta data to the value from datafy, but it seems to not work as I expect:

https://github.com/clojure/clojurescript/blob/master/src/main/cljs/clojure/datafy.cljs

ex from Clojure:

user=> (def x (with-meta [1 2 3] {`clojure.core.protocols/datafy (fn [_] [2 3 4])}))
#'user/x
user=> (d/datafy x)
[2 3 4]
user=> (meta (d/datafy x))
#:clojure.datafy{:obj [1 2 3], :class clojure.lang.PersistentVector}

in CLJS:

(def x (with-meta [1 2 3] {:clojure.datafy/datafy (fn [_] [2 3 4])}))

(d/datafy x)
;; => nil

(meta (d/datafy x))
;; => nil

there's also the case where the datafied value is a JS object and it throws:

(def x (with-meta [1 2 3] {:clojure.datafy/datafy (fn [_] #js {})}))

(d/datafy x)
;; => Error: No protocol method IWithMeta.-with-meta defined for type object: [object Object]


 Comments   
Comment by William Acton [ 13/Dec/18 12:03 PM ]

For reference, Clojure handles the case of an arbitrary Java object without error:

user=> (def x (with-meta [1 2 3] {`clojure.core.protocols/datafy (fn [_] (Object.))}))
#'user/x
user=> (d/datafy x)
#object[java.lang.Object 0x3381b4fc "java.lang.Object@3381b4fc"]
user=> (meta (d/datafy x))
nil

Comment by William Acton [ 13/Dec/18 10:14 PM ]

Patch as discussed in Slack. Also tests.

Comment by David Nolen [ 14/Dec/18 10:55 AM ]

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





Generated at Tue Dec 18 19:16:25 CST 2018 using JIRA 4.4#649-r158309.