cherry

john 2024-10-03T22:07:43.425849Z

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?

borkdude 2024-10-04T11:07:34.011049Z

I'm a bit busy but I'll reply later today

borkdude 2024-10-04T18:13:05.888759Z

can you maybe make some kind of step by step repro?

borkdude 2024-10-04T18:13:15.307319Z

preferably in a Github repo, not in slack

john 2024-10-04T18:13:51.265019Z

Yup!

borkdude 2024-10-04T18:20:40.922889Z

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

πŸ™Œ 1
borkdude 2024-10-04T18:21:02.601529Z

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)

πŸ‘ 1
borkdude 2024-10-04T18:21:35.250169Z

I think this is actually already a repro: https://squint-cljs.github.io/squint/?src=KG5zIGZvby5iYXIpCgooZGVmIHggMSkKCmZvby5iYXIveA%3D%3D

john 2024-10-04T18:24:30.405559Z

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!

john 2024-10-04T18:25:18.080869Z

I think I figured out this issue I was having porting cljs-thread over

john 2024-10-04T18:25:59.381979Z

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

john 2024-10-05T02:50:55.371499Z

Yup that's it

john 2024-10-05T02:53:24.109889Z

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

john 2024-10-05T02:54:22.867179Z

Or is there some edge case where that wouldn't be true?

john 2024-10-05T03:03:55.038389Z

uuuh, not aliases, but the :as things in the ns-state

john 2024-10-05T03:04:41.158829Z

oh yeah, it's called aliases in the ns-state

borkdude 2024-10-05T06:40:14.722109Z

Yeah I think that’s reasonable. Also it should also not be a name in the current namespaces refers or defined vars.

john 2024-10-03T22:09:08.727719Z

By break I mean #object[TypeError TypeError: Cannot read properties of undefined (reading 'bar')]

john 2024-10-03T22:15:03.289479Z

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

borkdude 2024-10-05T10:45:32.001849Z

Fixed in cherry 0.3.23

πŸŽ‰ 1