I'm fiddling with cherry and I'm using cherry.compiler.node/compile-string and somehow I've got things messed up where I can send forms that refer to vars in the current namespace when they're unqualified. But when they're qualified, they break. When I run (p-c+e "foo.bar/a") I can see in the output return globalThis.foo.bar.foo.bar.a; in there, so it looks like it's reading foo.bar/a as a single symbol and is then adding that whole thing to the actual foo.bar namespace? Ever seen that? Is there something I'm obvious I'm messing up in the :opts maybe?
I'm a bit busy but I'll reply later today
can you maybe make some kind of step by step repro?
preferably in a Github repo, not in slack
Yup!
I think I know what the issue is. There isn't any logic to detect if a symbol refers to a global namespace (or the current namespace). It just always assumes a symbol (that isn't detected via the ns form) refers to something in the current namespace
You can hack around this with js/foo.bar but feel free to post an issue about this in the squint repo (I'll fix it there first and then in cherry)
I think this is actually already a repro: https://squint-cljs.github.io/squint/?src=KG5zIGZvby5iYXIpCgooZGVmIHggMSkKCmZvby5iYXIveA%3D%3D
this is a workaround: https://squint-cljs.github.io/squint/?src=KG5zIGZvby5iYXIpCgooZGVmIHggMSkKCihucyBkdWRlKQoKanMvZm9vLmJhci54
K I'm afk for like 4 more hours but I'll try that when I get back. Thanks for looking into this. Cherry is getting exciting!
I think I figured out this issue I was having porting cljs-thread over
And there's lots of questions about the best way to go about doing that with cherry over postMessage, etc, but I'll ping you when I'm there
Yup that's it
> There isn't any logic to detect if a symbol refers to a global namespace (or the current namespace).
If we see that it's a qualified symbol, and it's not in the :aliases coll, can't we assume it refers to a global?
Or is there some edge case where that wouldn't be true?
uuuh, not aliases, but the :as things in the ns-state
oh yeah, it's called aliases in the ns-state
Yeah I think thatβs reasonable. Also it should also not be a name in the current namespaces refers or defined vars.
By break I mean #object[TypeError TypeError: Cannot read properties of undefined (reading 'bar')]
I'm using :repl true and :context :return. To get the behavior I wanted I did some hacky things:
(do (set! js/cherry_core cljs.core) nil)
(def default-cs
(merge
{:repl true
:elide-imports true
:elide-exports true
:context :return}
(when (undefined? js/cherry_core)
{:core-alias 'cljs.core})))Fixed in cherry 0.3.23