clojure.repl/source chokes when reading code with ::auto/resolved keys

Description

Reproduction

foo.clj

repl

Problem analysis
source calls read, without any underlying binding or notion of Compiler.currentNS(), which causes aliased keywords to fail to resolve.

Possible solution
Bind *reader-resolver* to the following before reading:

Aside, the logic inside source-fn can be simplified with read+string, modulo CLJ-2358

Environment

None

Activity

Show:

Michiel Borkent May 6, 2024 at 12:10 PM
Edited

Note that the “possible” solution needs a little change as reading this will fail:

as both aliases resolve to ignored and this will result in duplicate keys.

Michiel Borkent December 24, 2020 at 9:46 PM
Edited

Another small issue:

source-fn could probably also skip some columns (this information is also available on the var), so it can parse the source for bar in:

Executing (source bar) will print the source for foo right now.

Details

Assignee

Reporter

Priority

Created June 13, 2018 at 3:28 AM
Updated May 6, 2024 at 6:06 PM