Skip to content

Fix --interactive irb mode not printing eval results#108

Merged
SamSaffron merged 3 commits into
tmm1:masterfrom
OsamaSayegh:fix-irb-output-release
Jun 18, 2026
Merged

Fix --interactive irb mode not printing eval results#108
SamSaffron merged 3 commits into
tmm1:masterfrom
OsamaSayegh:fix-irb-output-release

Conversation

@OsamaSayegh

@OsamaSayegh OsamaSayegh commented May 18, 2026

Copy link
Copy Markdown
Contributor

IRB 1.x's output_value passes a buffer to inspect_last_value and reads from it when paging is enabled and the inspector supports streaming, which is the default TTY case. The override returned @last_value but never wrote to the buffer, so nothing was printed. We need to append @last_value to the buffer instead to get the inspected value printed.

IRB 1.x's output_value passes a buffer to inspect_last_value and reads
from it (stream-output pattern) when paging is enabled and the
inspector supports streaming, which is the default TTY case. The
override returned @last_value but never wrote to the buffer, so
nothing was printed. Append @last_value to the buffer instead.
@OsamaSayegh

Copy link
Copy Markdown
Contributor Author

@SamSaffron, would love a review from you on this please.

def inspect_last_value(output = +"")
@last_value
output << @last_value.to_s
end

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow this is confusing code ... why is it even taking in output ... why is it mutating it? I think we need some sort of test here that explains this ... what was the original intent here?

@OsamaSayegh OsamaSayegh Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok @SamSaffron I've added an end-to-end test here. it should catch future regressions if/when IRB shuffles its internals again.

@SamSaffron SamSaffron merged commit 753fe9d into tmm1:master Jun 18, 2026
4 checks passed
@SamSaffron

Copy link
Copy Markdown
Collaborator

thanks, cut a new gem

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.

2 participants