Skip to content

Etapa 1: cleanup, dependency hygiene, and DAP/LSP foundation#44

Merged
jig merged 3 commits into
mainfrom
cleanup/sparkling-dawn
Apr 30, 2026
Merged

Etapa 1: cleanup, dependency hygiene, and DAP/LSP foundation#44
jig merged 3 commits into
mainfrom
cleanup/sparkling-dawn

Conversation

@jig
Copy link
Copy Markdown
Owner

@jig jig commented Apr 30, 2026

Summary

Etapa 1 of the jig/lisp review (see ~/.claude/plans/revisa-el-jig-lisp-amb-sparkling-dawn.md for full plan). Surgical cleanup plus a few quality wins to prepare the tree for Etapa 2 (DAP/LSP design, planned separately). No structural refactor.

What's in the three commits

  1. cleanup: drop debug residue and unused dependencies — delete commented-out fmt.Printf/fmt.Println left from development; drop unused direct deps eiannone/keyboard and fatih/color (with their orphaned indirects); resolve the long-standing TODO in lisperror.Error so (throw {:a 1}) renders as Lisp data instead of Go reflection output.

  2. propagate cursor on synthetic AST nodes; consolidate error wrappingEVAL synthesizes List values for do/try/catch/finally/fn bodies and TCO arg-binding; copy the parent Cursor onto each so errors raised inside them carry a position. Wrap a stray fmt.Errorf in reader.read_external with lisperror.NewLispError. Document DebugEvalEnabled as the public hook point for external debuggers, and document lib/core's nil-Cursor convention for runtime-constructed lists.

  3. add tests for -e/--eval flag and Env.Symbols completion — covers the new -e/--eval paths (success, conflicts with --version and --test, combined script + -e) and pins down Env.Symbols behaviour for the upcoming LSP work.

Notable changes that affect users

  • (throw <non-error>) errors now print the payload via printer.Pr_str, e.g. (throw {:a 1}) reports {:a 1} instead of Go's map[string]interface{}{...} reflection format. (Caught throws are unaffected.)
  • Errors raised inside try/catch/finally bodies now consistently carry a source position.
  • Type errors from external constructors («...» reader syntax) now carry a position.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./...
  • Smoke: go run ./cmd/lisp -e '(+ 1 2)'3
  • Smoke: go run ./cmd/lisp -e '(try (/ 1 0) (catch e e))' → caught error
  • Smoke: go run ./cmd/lisp -e '(throw {:a 1})' → renders {:a 1} (not Go reflection)
  • Smoke: go run ./cmd/lisp --debug -e '(do (def DEBUG-EVAL true) (+ 1 2))' → still shows DEBUG-EVAL traces with positions

Out of scope (deferred for Etapa 2 or later)

  • DAP / LSP design and implementation
  • Restructuring mal.go's 681-line EVAL
  • Replacing MalType = interface{} with concrete types
  • types.ConvertTo removal: it's exported with no internal callers, but external embedders may use it; reassess in a future minor-version bump
  • Concurrent eval / future hardening: TestFileTests has a pre-existing -race warning under lib/concurrent (verified present on main); intentionally untouched

🤖 Generated with Claude Code

jig and others added 3 commits April 30, 2026 12:08
Remove commented-out fmt.Printf/fmt.Println debug calls left from
development across types, printer, lisperror, placeholder_test, and
runtest_test. Drop commented-out type cases and method stubs that no
longer compile against current types (printer's lisperror.LispError and
*types.Atom branches; lisperror's LispPrint and Type stubs that were
superseded by the active LispPrint at the bottom of the file).

Drop unused direct dependencies github.com/eiannone/keyboard and
github.com/fatih/color from go.mod; go mod tidy removed mattn/go-colorable
and mattn/go-isatty as they were only pulled in by fatih/color. ANSI
escapes are written as raw strings, no library needed.

Resolve the long-standing TODO in lisperror.Error: non-error MalType
payloads (e.g. (throw {:a 1})) now render via printer.Pr_str so they
print as Lisp data instead of Go reflection output.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
EVAL synthesizes List values for several special forms. Until now those
synthetic lists carried a nil Cursor, which meant errors raised inside
them surfaced with a missing source position. Copy the parent cursor
onto each synthetic list:

- the do helper used by try/catch/finally bodies
- the (catch ...) and (finally ...) bodies (reuse their own form's cursor)
- the synthetic (do ...) wrapper that backs (fn ...) bodies
- the argument list rebound during tail-call optimisation

Wrap a stray fmt.Errorf in reader.read_external with lisperror.NewLispError
so external constructor type errors carry a position too.

Document lib/core's nil-Cursor convention for runtime-constructed lists
(map, cons, concat, ...) and add a comment on sPew clarifying that it
backs the (spew x) builtin via the lib/call name-lowercasing dispatcher.

Expand the doc comment on DebugEvalEnabled to record that it is the
public extension point for external debuggers; an upcoming DAP/LSP
integration will hook here.

Add a regression test (TestTryFinallyBodyHasCursor) asserting that an
error from inside a try body now carries a non-nil position.

Also delete the remaining commented-out fmt.Printf debug lines in
mal.go's EVAL switch and reader's tokenizer loop.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Cover command.Execute paths that the recent -e/--eval flag introduced:
the success path, the conflict errors with --version and --test, and
the combined "script + -e" path where the script result is suppressed
in favour of the eval result.

Add correctness tests for env.Env.Symbols, used today by the REPL's
readline autocomplete and slated for reuse in the upcoming LSP work:
prefix match in the current scope, prefix match through outer scopes,
sorted ordering per scope on the empty prefix, and a documenting test
pinning current behaviour around shadowed symbols (reported once per
scope they occur in, not deduplicated).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jig jig merged commit 6a31817 into main Apr 30, 2026
4 checks passed
@jig jig deleted the cleanup/sparkling-dawn branch April 30, 2026 12:24
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