Skip to content

EVAL_HISTORY is busted #774

Closed
Closed

Description

@zenspider

with IRB.conf[:EVAL_HISTORY] = true everything is busted:

9972 % irb
>> 1  + 2
/Users/ryan.davis/.rubies/ruby-3.2.2/lib/ruby/3.2.0/irb/ext/history.rb:127:in `>': comparison of Integer with true failed (ArgumentError)

      @contents.shift if @size != 0 && @contents.size > @size
                                                        ^^^^^
	from /Users/ryan.davis/.rubies/ruby-3.2.2/lib/ruby/3.2.0/irb/ext/history.rb:127:in `push'
	from /Users/ryan.davis/.rubies/ruby-3.2.2/lib/ruby/3.2.0/irb/ext/history.rb:26:in `set_last_value'

even irb_info

current .irbrc:

IRB.conf[:PROMPT_MODE]      = :SIMPLE
IRB.conf[:USE_AUTOCOMPLETE] = false
IRB.conf[:USE_COLORIZE]     = false

# maybe?

IRB.conf[:EVAL_HISTORY]     = true

Activity

  1. added
    bug
    on Nov 20, 2023
  2. tompng commented on Nov 21, 2023

    @tompng
    Member

    IRB.conf[:EVAL_HISTORY] should be number or nil.

    Do you think IRB needs type validation for configs?
    Or EVAL_HISTORY=true should enable EVAL_HISTORY with some default size? (maybe about 10?)

    These are some other confusing configs and invalid values that raise error.

    IRB.conf[:IRB_NAME] = :ruby # should be string
    IRB.conf[:IRB_RC] = '/path/to/.irbrc' # should be proc
    IRB.conf[:BACK_TRACE_LIMIT] = ENV['IRB_BT_LIM'] # should be number
    IRB.conf[:PROMPT] = '>> ' # should be hash
  3. st0012 commented on Nov 22, 2023

    @st0012
    Member

    Yeah both type validation and better documentation (discovery) are needed for those configs.

    IRB.conf[:IRB_NAME] = :ruby # should be string

    For this we should also support symbol, or even anything that responds to to_s?

    Or EVAL_HISTORY=true should enable EVAL_HISTORY with some default size?

    SAVE_HISTORY also doesn't support true (it has a default of 1000 though). So for consistency I'd say no, unless we want to change them both?

  4. zenspider commented on Nov 30, 2023

    @zenspider
    MemberAuthor

    That's totally on me. I should have noticed that some default values were nil and some were not. I don't think we need full type checking, but some defensive programming would be nice... and doco. always doco

  5. zenspider commented on Mar 18, 2024

    @zenspider
    MemberAuthor

    @st0012 want me to file a separate bug against doco and type checking?

  6. st0012 commented on May 6, 2024

    @st0012
    Member

    @zenspider Sorry for the delay. I've now cleared other priorities and will start looking at this. For the start I'll target the configs listed here, so feel free to add new ones.

  7. st0012 commented on May 6, 2024

    @st0012
    Member

    Actually, I think I'll close this with #953. If you find other configs can use the same improvement, please open new ones 😄

  8. zenspider commented on May 6, 2024

    @zenspider
    MemberAuthor

    #953 feels like the right thing to do. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions