cljs-dev

lilactown 2024-04-17T16:43:26.312979Z

just realized the repo was private- is public now

dnolen 2024-04-17T18:06:41.843559Z

https://clojure.atlassian.net/browse/CLJS-3412

dnolen 2024-04-17T18:07:35.556069Z

I do wonder if it’s reader bug? haven’t had a chance to look closely

john 2024-04-17T18:16:29.942049Z

Seems true for normal :as aliases as well?

john 2024-04-17T18:17:22.168079Z

other reader tags are handling a space just fine

john 2024-04-17T18:18:50.527509Z

Yeah, clj handles the space just fine for map prefixes

john 2024-04-17T18:22:26.311799Z

Well, when you read ::b, you think :this.namespace/b, moreso than :alias.for.b/thing-a-number-of-white-spaces-from-here

john 2024-04-17T18:24:07.385639Z

So there's a slight argument for map namespace prefixes being slightly stricter than other reader tags, wrt whitespace

dnolen 2024-04-17T18:27:31.757979Z

@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

john 2024-04-17T18:28:02.340729Z

That's what I'm thinking, and seeing in the repl I think

john 2024-04-17T18:28:17.896599Z

I think that's what @lilactown was getting at

john 2024-04-17T18:28:38.984769Z

about the space. I think the as-alias is working without the space

dnolen 2024-04-17T18:29:10.134889Z

@bronsa what do you think ^?

bronsa 2024-04-17T18:33:11.699649Z

I'm a bit surprised the whitespace would be read into the symbol, but let me have a look

john 2024-04-17T18:34:40.037999Z

I'm pretty sure this behavior has always been there

john 2024-04-17T18:34:49.479899Z

Don't think it's a regression

john 2024-04-17T18:37:52.804679Z

Because I think I've wondered about the above rationale for the stricter syntax in the past

john 2024-04-17T18:39:55.553489Z

from working on perc in the past

bronsa 2024-04-17T18:42:34.960109Z

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

john 2024-04-17T18:45:40.276909Z

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?

dnolen 2024-04-17T18:45:54.301039Z

hrm actually maybe not the reader - since app.b is resolved in the reported error …

bronsa 2024-04-17T18:46:33.994359Z

yeah that's what I'm thinking too

bronsa 2024-04-17T18:47:06.631089Z

but they really should produce the same object, so something the reader produces is different -- perharps the meta?

bronsa 2024-04-17T18:46:20.143479Z

the whitespace is immaterial during reading

john 2024-04-17T18:47:03.971279Z

how do you know you've reached the end of a locally namespaced some-key?

dnolen 2024-04-17T18:47:11.448989Z

@john which makes it stranger that dropping the space works …

john 2024-04-17T18:48:47.762529Z

Maybe the clj one isn't trying to resolve, at the stage it's reading from the reader tag itself

bronsa 2024-04-17T18:49:14.900249Z

is there a quick way I can repro in a cljs repl? sorry it's been a while since I've played with cljs

john 2024-04-17T18:49:45.484539Z

(ns user
  (:require
   [clojure.edn :as edn]))
(def data #::edn {:x 1 :y 2 :z 3})

bronsa 2024-04-17T18:50:02.324359Z

right

john 2024-04-17T18:50:06.925389Z

should do it. I just use calva to launch my cljs envs quickly these days

john 2024-04-17T18:50:12.791489Z

with shadow

dnolen 2024-04-17T18:51:00.646719Z

@bronsa from ClojureScript repo - clj -M -m cljs.main -re node -r

👍 1
dnolen 2024-04-17T18:51:18.341649Z

I see the reported error after dropping the forms into the REPL

bronsa 2024-04-17T18:52:54.077629Z

weird, I don't O.o

bronsa 2024-04-17T18:53:02.924729Z

user=> (def data #::edn {:x 1 :y 2 :z 3})
#'user/data
user=> data
#:clojure.edn{:x 1, :y 2, :z 3}

bronsa 2024-04-17T18:53:19.418849Z

ClojureScript 1.11.54

bronsa 2024-04-17T18:53:32.669119Z

let me try to upgrade

bronsa 2024-04-17T18:54:25.645239Z

same on 1.11.132

john 2024-04-17T18:55:40.747789Z

Hmm, I wasn't seeing it in the node repl

bronsa 2024-04-17T18:57:17.486119Z

if it's env specific it may point to the problem not being the reader

john 2024-04-17T18:57:58.413999Z

ah, I'm on an older version of cljs too

john 2024-04-17T18:58:05.169339Z

maybe it is a regression

bronsa 2024-04-17T18:58:10.929529Z

@john out of curiosity, in wherever env you can repro, does (def data '#::edn {:x 1 :y 2 :z 3}) make a difference?

p-himik 2024-04-17T18:59:44.326459Z

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.

p-himik 2024-04-17T19:02:46.770509Z

@thheller Pinging you since you might want to know.

bronsa 2024-04-17T19:00:46.272829Z

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.

lilactown 2024-04-17T19:01:04.558559Z

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=>

lilactown 2024-04-17T19:02:13.852739Z

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}

john 2024-04-17T19:06:04.465009Z

(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

john 2024-04-17T19:07:24.516639Z

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

dnolen 2024-04-17T19:10:01.388829Z

k thanks all for the extra info

john 2024-04-17T19:10:21.654769Z

@bronsa

(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 )

john 2024-04-17T19:10:49.717019Z

doesn't even compile, but that map is returned and printed

p-himik 2024-04-17T19:19:37.443089Z

How exactly did you check that? What was the command that started your REPL?

john 2024-04-17T19:24:28.452179Z

So I just started shadow via calva's "jack-in" command. And then I just evaluated the form in the editor

p-himik 2024-04-17T19:25:10.189479Z

Did you see my comment above? Where I could reproduce it only in shadow-cljs but not in vanilla CLJS.

p-himik 2024-04-17T19:25:29.496909Z

So if anything, the space-related issue seems to be purely on the shadow-cljs side.

john 2024-04-17T19:25:49.339599Z

I did see that. That could well be it. Might need to bring this to shadow-cljs

p-himik 2024-04-17T19:26:19.146739Z

Right, that's why I pinged Thomas in that thread.

john 2024-04-17T19:27:00.308169Z

Did you try the latest cljs on a vanilla node repl and try it?

p-himik 2024-04-17T19:27:33.191549Z

Yes, exactly as my comment mentions.

p-himik 2024-04-17T19:27:41.381679Z

> can't reproduce the issue with :as and a space with the latest vanilla CLJS with both Node and browser-based REPL

john 2024-04-17T19:27:57.455649Z

Ah okay

john 2024-04-17T19:29:49.291629Z

ah, looks like Thomas has seen it in the shadow channel and is aware

john 2024-04-17T19:11:02.321849Z

so data is still not defined

john 2024-04-17T19:14:21.849509Z

So correction, this behavior doesn't appear to be present on 1.10.520

lilactown 2024-04-17T00:36:53.414819Z

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

dnolen 2024-04-17T00:46:51.663219Z

@lilactown thanks!!!