Skip to content

Fix stale aliases and refers after a reload - #83

Merged
bbatsov merged 1 commit into
mainfrom
repair-aliases-after-reload
Nov 6, 2026
Merged

bbatsov merged 1 commit into
mainfrom
repair-aliases-after-reload

Conversation

@bbatsov

@bbatsov bbatsov commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

After ,autoreload, eval --reload or reload, the REPL's aliases and refers stayed on the namespaces the reload replaced, so a function added since didn't resolve through them, and requiring with the same alias again failed. cider-nrepl's reload middleware would be a better home, covering every client, but 0.64.0 doesn't do it.

@bbatsov
bbatsov force-pushed the repair-aliases-after-reload branch from 779e2e6 to 2e1772a Compare November 6, 2026 09:18
cider-nrepl's refresh and clj-reload both reload a namespace by removing
it and loading it again as a new object. The namespaces they don't
reload, like the REPL's user, keep their aliases and refers on the old
one, so a function added to the file since doesn't resolve through the
alias, and requiring the namespace again with the same alias fails with
"Alias o already exists". clj-reload's README calls this out.

After a reload that reloaded something, neorepl now goes over every
namespace and points those aliases and refers at the namespace that has
the name now, and its var by the same name. Anything without a
replacement stays as it was, which keeps :as-alias keywords working and
doesn't throw away what another client's reload is about to bring back.
The check goes by the var's own namespace and name rather than its
metadata, since potemkin's import-vars copies another var's :ns and
:name. Both reloads are Clojure only, so the code is too.
@bbatsov
bbatsov force-pushed the repair-aliases-after-reload branch from 2e1772a to 9cf7ecc Compare November 6, 2026 13:44
@bbatsov
bbatsov merged commit 22e2d05 into main Nov 6, 2026
20 checks passed
@bbatsov
bbatsov deleted the repair-aliases-after-reload branch November 6, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant