This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-04-17
Channels
- # announcements (8)
- # babashka (27)
- # beginners (60)
- # biff (7)
- # calva (3)
- # cider (10)
- # cljs-dev (69)
- # clojure (18)
- # clojure-europe (12)
- # clojure-hungary (1)
- # clojure-korea (2)
- # clojure-new-zealand (12)
- # clojure-nl (1)
- # clojure-norway (80)
- # clojure-uk (9)
- # clojurescript (55)
- # cursive (69)
- # data-science (16)
- # events (5)
- # helix (11)
- # hyperfiddle (23)
- # jobs (1)
- # lsp (5)
- # malli (14)
- # matrix (1)
- # missionary (2)
- # off-topic (40)
- # portal (31)
- # re-frame (17)
- # reitit (11)
- # releases (11)
- # shadow-cljs (4)
- # squint (4)
- # tools-deps (5)
- # yamlscript (4)
I believe I've found a bug in :as-alias
when combined with namespaced maps.
$ cat src/app/a.cljs
(ns app.a
(:require
[app.b :as-alias b]))
;; works
#_(def data {::b/x 1 ::b/y 2 ::b/z 3})
;; broken
(def data #::b {:x 1 :y 2 :z 3})
$ clj -M --main cljs.main --compile app.a
Unexpected error compiling at (REPL:1).
No namespace: app.b found
Full report at:
/var/folders/28/7xm2frlx1cb_gt4nrscjpttw0000gn/T/clojure-10509037535418893124.edn
full repro here: https://github.com/lilactown/cljs-alias-ns-map-bug@lilactown thanks!!!
Well, when you read ::b
, you think :this.namespace/b
, moreso than :alias.for.b/thing-a-number-of-white-spaces-from-here
So there's a slight argument for map namespace prefixes being slightly stricter than other reader tags, wrt whitespace
@john so you’re saying normal :as
fails as well and the problem is #::b{...}
vs #::b {…}
- will update the description if this is what you mean
I think that's what @lilactown was getting at
I'm a bit surprised the whitespace would be read into the symbol, but let me have a look
Because I think I've wondered about the above rationale for the stricter syntax in the past
I'm struggling to see how #::x{:foo 1}
#::x {:foo 1}
would be any different tbh. I don't think the whitespace matters, it may be a red herring
Is the reader tag for namespaced keys being checked prior to the one for catching map namepsace prefixes? If not, then the white space would be forcing a namespaced key read, right?
but they really should produce the same object, so something the reader produces is different -- perharps the meta?
Maybe the clj one isn't trying to resolve, at the stage it's reading from the reader tag itself
is there a quick way I can repro in a cljs repl? sorry it's been a while since I've played with cljs
user=> (def data #::edn {:x 1 :y 2 :z 3})
#'user/data
user=> data
#:clojure.edn{:x 1, :y 2, :z 3}
@john out of curiosity, in wherever env you can repro, does (def data '#::edn {:x 1 :y 2 :z 3})
make a difference?
FWIW, can't reproduce the issue with :as
and a space with the latest vanilla CLJS with both Node and browser-based REPL.
Can reproduce with shadow-cljs 2.28.3 (uses same CLJS version under the hood, 132). Adding a quote doesn't change anything.
@U05224H0W Pinging you since you might want to know.
ok I tested removing the whitespace in cljs-alias-ns-map-bug
and that doesn't seem to make a difference at least, so we can exclude that.
yeah I just tested this in that repo
$ clj -M -m cljs.main -re node -r
ClojureScript 1.11.132
cljs.user=> (ns a.b (:require [a.c :as-alias c]))
nil
a.b=> ::c/x
:a.c/x
a.b=> #::c{:x 1}
Syntax error reading source at (REPL:1).
No namespace: a.c found
:x
1
Syntax error reading source at (REPL:1).
<NO_SOURCE_FILE> [line 1, col 2] Unmatched delimiter }.
a.b=>
can't repro the space issue with :as
clj -M -m cljs.main -re node -r
ClojureScript 1.11.132
cljs.user=> (ns a.b (:require [clojure.edn :as edn]))
nil
a.b=> ::edn/x
:clojure.edn/x
a.b=> #::edn{:x 1}
#:clojure.edn{:x 1}
a.b=> #::edn {:x 1}
#:clojure.edn{:x 1}
(ns user.core
(:require [cljs.math :as m]))
::m/hi ;=> :cljs.math/hi
#::cljs.math {:hi :there} ;=> #:cljs.math{:hi :there}
#::cljs.math{:hi :there} ;=> #:cljs.math{:hi :there}
#::m {:hi :there} ;=> {:hi :there}
; No namespace: m found
#::m{:hi :there} ;=> :there
; No namespace: m found
So, correction, what I'm seeing is happening regardless of a space, just aliasing in general, hmm.. But I'm seeing different behavior in the vanilla node repl I think
(def data '#::edn {:x 1 :y 2 :z 3}) ;=> {:x 1, :y 2, :z 3}
; No namespace: edn found
; [line 1, col 2] Unmatched delimiter )
So I just started shadow via calva's "jack-in" command. And then I just evaluated the form in the editor
Did you see my comment above? Where I could reproduce it only in shadow-cljs but not in vanilla CLJS.