Etapa 1: cleanup, dependency hygiene, and DAP/LSP foundation#44
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Etapa 1 of the jig/lisp review (see
~/.claude/plans/revisa-el-jig-lisp-amb-sparkling-dawn.mdfor 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
cleanup: drop debug residue and unused dependencies — delete commented-out
fmt.Printf/fmt.Printlnleft from development; drop unused direct depseiannone/keyboardandfatih/color(with their orphaned indirects); resolve the long-standing TODO inlisperror.Errorso(throw {:a 1})renders as Lisp data instead of Go reflection output.propagate cursor on synthetic AST nodes; consolidate error wrapping —
EVALsynthesizesListvalues fordo/try/catch/finally/fnbodies and TCO arg-binding; copy the parentCursoronto each so errors raised inside them carry a position. Wrap a strayfmt.Errorfinreader.read_externalwithlisperror.NewLispError. DocumentDebugEvalEnabledas the public hook point for external debuggers, and documentlib/core's nil-Cursor convention for runtime-constructed lists.add tests for -e/--eval flag and Env.Symbols completion — covers the new
-e/--evalpaths (success, conflicts with--versionand--test, combined script +-e) and pins downEnv.Symbolsbehaviour for the upcoming LSP work.Notable changes that affect users
(throw <non-error>)errors now print the payload viaprinter.Pr_str, e.g.(throw {:a 1})reports{:a 1}instead of Go'smap[string]interface{}{...}reflection format. (Caught throws are unaffected.)try/catch/finallybodies now consistently carry a source position.«...»reader syntax) now carry a position.Test plan
go build ./...go vet ./...go test ./...go run ./cmd/lisp -e '(+ 1 2)'→3go run ./cmd/lisp -e '(try (/ 1 0) (catch e e))'→ caught errorgo run ./cmd/lisp -e '(throw {:a 1})'→ renders{:a 1}(not Go reflection)go run ./cmd/lisp --debug -e '(do (def DEBUG-EVAL true) (+ 1 2))'→ still shows DEBUG-EVAL traces with positionsOut of scope (deferred for Etapa 2 or later)
mal.go's 681-lineEVALMalType = interface{}with concrete typestypes.ConvertToremoval: it's exported with no internal callers, but external embedders may use it; reassess in a future minor-version bumpfuturehardening:TestFileTestshas a pre-existing-racewarning underlib/concurrent(verified present onmain); intentionally untouched🤖 Generated with Claude Code