ruby / ruby/irb

Allow inspecting implicit parameters via `implicit_parameter_get` etc.

Open
#1,210 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
478
Forks
158
Avg merge
1d 12h
Merged PRs (30d)
12

Description

Currently, it is not possible to know what implicit parameters like it/_1 actually are. If I want to know, I have to rewrite the block to take explicit parameters.

[1, 2, 3].each do
  puts it
  binding.irb
end
$ ruby test.rb
1

From: test.rb @ line 3 :

    1: [1, 2, 3].each do
    2:   puts it
 => 3:   binding.irb
    4: end

irb(main):001> it
/home/user/code/test/test.rb(irb):1:in 'block in <main>': undefined local variable or method 'it' for main (NameError)
        from test.rb:3:in 'Binding#irb'
        from test.rb:3:in 'block in <main>'
        from test.rb:1:in 'Array#each'
        from test.rb:1:in '<main>'

Ruby 4.0 actually added methods to interogate the values of such params (https://bugs.ruby-lang.org/issues/21049#note-7) and it would be great if it can just work in irb.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading Ruby 4.0's implicit-parameter interrogation methods referenced in the linked Ruby issue and the binding.irb behavior shown in the example. Trace how IRB evaluates names such as it and _1, then verify that implicit_parameter_get and related methods can inspect them from the session without rewriting the block.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.