This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-10
Channels
- # announcements (3)
- # beginners (67)
- # calva (4)
- # cider (3)
- # clj-kondo (58)
- # cljs-dev (4)
- # clojure (172)
- # clojure-berlin (4)
- # clojure-chicago (8)
- # clojure-europe (4)
- # clojure-greece (8)
- # clojure-italy (12)
- # clojure-nl (4)
- # clojure-spec (7)
- # clojure-uk (77)
- # clojurescript (13)
- # clojutre (16)
- # core-async (10)
- # cursive (3)
- # datomic (29)
- # figwheel-main (27)
- # fulcro (22)
- # garden (3)
- # jobs (2)
- # jobs-discuss (13)
- # juxt (5)
- # leiningen (14)
- # mount (4)
- # off-topic (28)
- # pathom (6)
- # pedestal (8)
- # portland-or (2)
- # re-frame (20)
- # remote-jobs (6)
- # shadow-cljs (13)
- # sql (74)
- # testing (17)
- # tools-deps (1)
- # vim (1)
- # xtdb (1)
@anmonteiro sounds like a good idea to me. I reported this a few months ago and yours seems like a good solution. https://clojure.atlassian.net/browse/CLJS-3055
Hi! Is this an instance of garbage-in/garbage-out or is it a small regression?
(ns cljsbug.wat.fig)
(def a (rand-nth [nil]))
(when a (* a 2))
// Compiled by ClojureScript 1.10.339 {}
goog.provide('cljsbug.wat.fig');
goog.require('cljs.core');
cljsbug.wat.fig.a = cljs.core.rand_nth.call(null,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [null], null));
if(cljs.core.truth_(cljsbug.wat.fig.a)){
(cljsbug.wat.fig.a * (2));
} else {
}
// Compiled by ClojureScript 1.10.520 {}
goog.provide('cljsbug.wat.fig');
goog.require('cljs.core');
cljsbug.wat.fig.a = cljs.core.rand_nth.call(null,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [null], null));
if(cljs.core.truth_(cljsbug.wat.fig.a)){
(
The file is truncated, and there's the following NPE on the terminal:
java.lang.NullPointerException
clojure.core$namespace/invokeStatic at core.clj(1595)
clojure.core$namespace/invoke at core.clj(1589)
cljs.compiler$emit_var/invokeStatic at compiler.cljc(448)
cljs.compiler$emit_var/invoke at compiler.cljc(442)
cljs.compiler$fn__3341/invokeStatic at compiler.cljc(489)
cljs.compiler$fn__3341/invoke at compiler.cljc(489)
clojure.lang.MultiFn/invoke at MultiFn.java(229)
cljs.compiler$emit/invokeStatic at compiler.cljc(202)
cljs.compiler$emit/invoke at compiler.cljc(182)
cljs.compiler$emits/invokeStatic at compiler.cljc(209)
cljs.compiler$emits/invoke at compiler.cljc(204)
cljs.compiler$emits/invokeStatic at compiler.cljc(229)
cljs.compiler$emits/doInvoke at compiler.cljc(204)
clojure.lang.RestFn/applyTo at RestFn.java(157)
clojure.core$apply/invokeStatic at core.clj(657)
clojure.core$apply/invoke at core.clj(652)
cljs.compiler$emits/invokeStatic at compiler.cljc(210)
cljs.compiler$emits/invoke at compiler.cljc(204)
cljs.compiler$fn__3828/invokeStatic at compiler.cljc(1382)
cljs.compiler$fn__3828/invoke at compiler.cljc(1374)
clojure.lang.MultiFn/invoke at MultiFn.java(229)
cljs.compiler$emit/invokeStatic at compiler.cljc(202)
cljs.compiler$emit/invoke at compiler.cljc(182)
cljs.compiler$fn__3621/invokeStatic at compiler.cljc(1045)
cljs.compiler$fn__3621/invoke at compiler.cljc(1040)
clojure.lang.MultiFn/invoke at MultiFn.java(229)
cljs.compiler$emit/invokeStatic at compiler.cljc(202)
cljs.compiler$emit/invoke at compiler.cljc(182)
cljs.compiler$emits/invokeStatic at compiler.cljc(209)
cljs.compiler$emits/invoke at compiler.cljc(204)
Wrapping rand-nth
with a call to Math.round
(as in (js/Math.round (rand-nth [nil]))
seems to "fix" it:
// Compiled by ClojureScript 1.10.520 {}
goog.provide('cljsbug.wat.fig');
goog.require('cljs.core');
cljsbug.wat.fig.a = Math.round(cljs.core.rand_nth.call(null,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [null], null)));
if(cljs.core.truth_(cljsbug.wat.fig.a)){
(cljsbug.wat.fig.a * (2));
} else {
}
@aisamu Probably this known issue https://clojure.atlassian.net/browse/CLJS-3068
👌 4