Skip to content

Commit

Permalink
Fix -e arguments affecting *1, *2, *3 and *e (#915)
Browse files Browse the repository at this point in the history
Planck's evaluation logic treated evaluation of text entered at a REPL
and evaluation of arguments to `-e` the same. This resulted in the
result variables (`*1`, `*2`, `*3`) being set in both cases. As noted
in #659, this is not the behaviour of Clojure. This commit fixes #659 by
testing whether the evaluation is occurring in a REPL environment.
  • Loading branch information
pyrmont authored and mfikes committed May 7, 2019
1 parent 43d536a commit 59c7dd7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. This change
### Fixed
- Switch `strncpy` to `memcpy` to avoid GCC warning
- Backslash return return should produce "\n" ([661](https://github.com/planck-repl/planck/issues/661))
- `-e` affects `*1`, `*2`, `*3` ([#659](https://github.com/planck-repl/planck/issues/659))

## [2.22.0] - 2019-04-06
### Added
Expand Down
24 changes: 12 additions & 12 deletions planck-cljs/src/planck/repl.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1989,9 +1989,9 @@

(defn- process-1-2-3
[expression-form value]
(when-not
(or ('#{*1 *2 *3 *e} expression-form)
(ns-form? expression-form))
(when (and (:repl @app-env)
(not ('#{*1 *2 *3 *e} expression-form))
(not (ns-form? expression-form)))
(set! *3 *2)
(set! *2 *1)
(set! *1 value)))
Expand Down Expand Up @@ -2138,15 +2138,15 @@
cljs/*load-fn* load-fn
cljs/*eval-fn* (get-eval-fn)
tags/*cljs-data-readers* (data-readers)]
(if-not (= "text" source-type)
(process-execute-path source-value (assoc opts :source-path source-value))
(let [source-text source-value
first-form (eof-guarded-read source-text)]
(when (not= eof first-form)
(let [expression-form (and expression? first-form)]
(if (repl-special? expression-form)
(process-repl-special expression-form opts)
(process-execute-source source-text expression-form opts)))))))))
(case source-type
"path" (process-execute-path source-value (assoc opts :source-path source-value))
"text" (let [source-text source-value
first-form (eof-guarded-read source-text)]
(when (not= eof first-form)
(let [expression-form (and expression? first-form)]
(if (repl-special? expression-form)
(process-repl-special expression-form opts)
(process-execute-source source-text expression-form opts)))))))))

(defn- ^:export execute
[source expression? print-nil-expression? set-ns theme-id session-id]
Expand Down

0 comments on commit 59c7dd7

Please sign in to comment.