Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect completion suggestions #329

Closed
ashmaroli opened this issue Jan 9, 2022 · 3 comments
Closed

Incorrect completion suggestions #329

ashmaroli opened this issue Jan 9, 2022 · 3 comments

Comments

@ashmaroli
Copy link

Description

Expected to get valid suggestions based on referenced object.

Sample Code:

Lorem = Class.new

module Foo
  def lipsum
    @lipsum ||= Lorem.new
  end
end

require 'irb'
require 'irb/completion'

puts "Initializing with IRB #{IRB::VERSION}..\n\n"

IRB.setup(nil)
IRB::Irb.new.tap do |irb|
  irb.context.main.extend(Foo)
end.run

Actual Result

irb

Note that even though lipsum references an instance of an Lorem which is simply a base class, the completion suggestion displays
methods not defined in Lorem or any of the ancestors of Lorem.

Result of irb_info

irb(main):001:0> irb_info
=>
Ruby version: 2.7.5
IRB version: irb 1.4.1 (2021-12-25)
InputMethod: ReidlineInputMethod with Reline 0.3.1
.irbrc path: C:/Users/[USERNAME]/.irbrc
RUBY_PLATFORM: x64-mingw32
East Asian Ambiguous Width: 3
Code page: 437

Terminal Emulator

cmd.exe on Windows

Setting Files

Using just ~/.irbrc.

@aycabta
Copy link
Member

aycabta commented Jan 16, 2022

Due to side effects, completion of method call results is not possible at the moment. Please see the corresponding implementation.

@ashmaroli
Copy link
Author

Please see the corresponding implementation.

@aycabta Thank you for responding. Could you also point me to the test coverage for those set of lines?
(Just curious about deducing the rationale and expectations around the particular case).

@tompng
Copy link
Member

tompng commented Nov 15, 2023

Implementing completion for the provided sample code is extremely difficult because it needs one of these to determine the return value of method ipsum.

  • Perform static code analyze for every code evaluated inside IRB
  • Analyze RubyVM::InstructionSequence.of(method(:ipsum))

Closing as not planned.
However, the new type-completor (#734) will provide better completion for some cases.

@tompng tompng closed this as completed Nov 15, 2023
@tompng tompng closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants