irb
irb copied to clipboard
EVAL_HISTORY is busted
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
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
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?
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
@st0012 want me to file a separate bug against doco and type checking?
@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.
Actually, I think I'll close this with https://github.com/ruby/irb/pull/953. If you find other configs can use the same improvement, please open new ones 😄
#953 feels like the right thing to do. Thanks!