Skip to content

nrepl.middleware.print/print printer garbles lazy output into the result #903

Open
@PEZ

Description

@PEZ

Hi!

With nrepl.middleware.print/print, evaluating:

(for [[type amount] {:wood 2 :iron 2}]
  (println "\n--------\n" (str type " " amount)))

Gives a garbled result value, and no output.

With cider.nrepl.pprint/pr, it works fine.

Expected behavior

The output as out messages, and the result as value message.

Actual behavior

The output and result come garbled in a value message.

Steps to reproduce the problem

Calva's nrepl messages log:

1727018467380 -> sent 
{
  id: '124',
  op: 'eval',
  ns: 'mini.playground',
  session: 'bd20ade5-ce08-42c1-91d4-cfd96548d22b',
  code: '(for [[type amount] {:wood 2 :iron 2}]\n' +
    '  (println "\\n--------\\n" (str type " " amount)))',
  'nrepl.middleware.print/options': { 'right-margin': 120, length: 200 },
  'nrepl.middleware.print/print': 'cider.nrepl.pprint/pprint',
  file: '/Users/pez/Projects/teasers/src/mini/playground.clj',
  line: 16,
  column: 1,
  pprint: true
}

1727018467399 <- received 19ms
{
  id: '124',
  ns: 'mini.playground',
  session: 'bd20ade5-ce08-42c1-91d4-cfd96548d22b',
  value: '\n--------\n :wood 2\n(nil\n--------\n :iron 2\n nil)'
}

1727018467399 <- received 0ms
{
  id: '124',
  session: 'bd20ade5-ce08-42c1-91d4-cfd96548d22b',
  status: [ 'done' ]
}

Environment & Version information

cider-nrepl version

I'm using whatever Calva is using, but @alexander-yakushev has reproduced it with the latest snapshot.

Java version

openjdk version "21.0.1" 2023-10-17 LTS
OpenJDK Runtime Environment Zulu21.30+15-CA (build 21.0.1+12-LTS)
OpenJDK 64-Bit Server VM Zulu21.30+15-CA (build 21.0.1+12-LTS, mixed mode, sharing)

Operating system

MacOS Sonoma 14.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions