Skip to content

Fix #770 by moving var outside of value#812

Open
borkdude wants to merge 3 commits into
mainfrom
issue-770-sidecar
Open

Fix #770 by moving var outside of value#812
borkdude wants to merge 3 commits into
mainfrom
issue-770-sidecar

Conversation

@borkdude
Copy link
Copy Markdown
Collaborator

@borkdude borkdude commented Apr 21, 2026

Previously the result of a (def foo v) was stored as
{:var-from-def #'foo :var-snapshot v} inside :nextjournal/value.
Viewers that saw this map had to either opt out via :var-from-def?
or tolerate being handed a metadata wrapper instead of the value.
This caused #770 (crash on clerk/row + def) and produced confusing
output when viewer fns like clerk/row/col ran on defs.

Now the value itself goes in :nextjournal/value and the var
reference goes in :nextjournal.clerk/var-from-def on the wrapped
value. apply-viewer-to-result copies the sidecar forward, and
render-eval-viewer's :transform-fn reads it for SCI resolution.
Removes var-from-def?, var-from-def-viewer,
maybe-wrap-var-from-def, and the :var-from-def? opt-out flag.

Previously the result of a `(def foo v)` was stored as
`{:var-from-def #'foo :var-snapshot v}` inside `:nextjournal/value`.
Viewers that saw this map had to either opt out via `:var-from-def?`
or tolerate being handed a metadata wrapper instead of the value.
This caused #770 (crash on `clerk/row` + def) and produced confusing
output when viewer fns like `clerk/row`/`col` ran on defs.

Now the value itself goes in `:nextjournal/value` and the var
reference goes in `:nextjournal.clerk/var-from-def` on the wrapped
value. `apply-viewer-to-result` copies the sidecar forward, and
`render-eval-viewer`'s `:transform-fn` reads it for SCI resolution.
Removes `var-from-def?`, `var-from-def-viewer`,
`maybe-wrap-var-from-def`, and the `:var-from-def?` opt-out flag.
SCI evaluates a bare symbol `ns/foo` to the var's value (the atom),
but `(resolve 'ns/foo)` returns the var itself. Viewers like
`editor-sync-viewer` expect the atom, so the bare-symbol form is what
matches the old behavior.
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