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

Drop unused arguments in RubyLex #504

Merged
merged 2 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions lib/irb/ruby-lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def self.compile_with_errors_suppressed(code, line_no: 1)
end

# io functions
def set_input(io, p = nil, context:, &block)
def set_input(io, context:, &block)
@io = io
if @io.respond_to?(:check_termination)
@io.check_termination do |code|
Expand Down Expand Up @@ -116,22 +116,15 @@ def set_input(io, p = nil, context:, &block)
end
end

if p.respond_to?(:call)
@input = p
elsif block_given?
if block_given?
@input = block
else
@input = Proc.new{@io.gets}
end
end

def set_prompt(p = nil, &block)
p = block if block_given?
if p.respond_to?(:call)
@prompt = p
else
@prompt = Proc.new{print p}
end
def set_prompt(&block)
@prompt = block
end

ERROR_TOKENS = [
Expand Down
4 changes: 3 additions & 1 deletion test/irb/test_ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def ruby_lex_for_lines(lines, local_variables: [])

context = build_context(local_variables)
io = proc{ lines.join("\n") }
ruby_lex.set_input(io, io, context: context)
ruby_lex.set_input(io, context: context) do
lines.join("\n")
end
ruby_lex.lex(context)
ruby_lex
end
Expand Down