Skip to content

IRB crashing when using "dot" accessor inside interpolation in heredoc #392

Closed

Description

Description

I expected to access an object's property function and have completion suggestions, but it crashes as soon "." is typed in.

Example:

➜  pdc-integracao-bff git:(master) ✗ irb
irb(main):001:0" here=<<-SQL
irb(main):002:0" #{5/usr/lib/ruby/gems/3.0.0/gems/reline-0.3.1/lib/reline/line_editor.rb:1177:in `+': no implicit conversion of nil into String (TypeError)
        from /usr/lib/ruby/gems/3.0.0/gems/reline-0.3.1/lib/reline/line_editor.rb:1177:in `render_partial'
        from /usr/lib/ruby/gems/3.0.0/gems/reline-0.3.1/lib/reline/line_editor.rb:508:in `rerender'
        from /usr/lib/ruby/gems/3.0.0/gems/reline-0.3.1/lib/reline.rb:330:in `block (3 levels) in inner_readline'
        from /usr/lib/ruby/gems/3.0.0/gems/reline-0.3.1/lib/reline.rb:328:in `each'
        from /usr/lib/ruby/gems/3.0.0/gems/reline-0.3.1/lib/reline.rb:328:in `block (2 levels) in inner_readline'
        from /usr/lib/ruby/gems/3.0.0/gems/reline-0.3.1/lib/reline.rb:403:in `block in read_io'
        from /usr/lib/ruby/gems/3.0.0/gems/reline-0.3.1/lib/reline.rb:373:in `loop'
        from /usr/lib/ruby/gems/3.0.0/gems/reline-0.3.1/lib/reline.rb:373:in `read_io'
        from /usr/lib/ruby/gems/3.0.0/gems/reline-0.3.1/lib/reline.rb:326:in `block in inner_readline'
        from /usr/lib/ruby/gems/3.0.0/gems/reline-0.3.1/lib/reline.rb:324:in `loop'
        from /usr/lib/ruby/gems/3.0.0/gems/reline-0.3.1/lib/reline.rb:324:in `inner_readline'
        from /usr/lib/ruby/gems/3.0.0/gems/reline-0.3.1/lib/reline.rb:254:in `readmultiline'
        from /usr/lib/ruby/3.0.0/forwardable.rb:238:in `readmultiline'
        from /usr/lib/ruby/3.0.0/forwardable.rb:238:in `readmultiline'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb/input-method.rb:418:in `gets'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb.rb:539:in `block (2 levels) in eval_input'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb.rb:770:in `signal_status'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb.rb:538:in `block in eval_input'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb/ruby-lex.rb:284:in `lex'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb/ruby-lex.rb:253:in `block (2 levels) in each_top_level_statement'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb/ruby-lex.rb:250:in `loop'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb/ruby-lex.rb:250:in `block in each_top_level_statement'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb/ruby-lex.rb:249:in `catch'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb/ruby-lex.rb:249:in `each_top_level_statement'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb.rb:557:in `eval_input'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb.rb:491:in `block in run'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb.rb:490:in `catch'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb.rb:490:in `run'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/lib/irb.rb:419:in `start'
        from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
        from /usr/bin/irb:25:in `load'
        from /usr/bin/irb:25:in `<main>'

You can see the erro right after #{5, this is where I tried to type in ".".

Result of irb_info

irb(main):001:0> irb_info
=> 
Ruby version: 3.0.4                            
IRB version: irb 1.4.1 (2021-12-25)            
InputMethod: ReidlineInputMethod with Reline 0.3.1
RUBY_PLATFORM: x86_64-linux                    
LANG env: de_AT.UTF-8                          
East Asian Ambiguous Width: 1                  

Terminal Emulator

konsole 22.04.3

Setting Files

Are you using ~/.irbrc and ~/.inputrc?
No.

Activity

  1. tompng commented on Sep 28, 2022

    @tompng
    Member

    I think this is fixed by #391

    IRB colorized the code incorrectly. Line of number has changed, caused the error.

    irb(main):001:0> puts IRB::Color.colorize_code "here=<<-SQL\n\#{."
    here=<<-SQL#{..
    

    In master branch, it's now

    irb(main):001:0> puts IRB::Color.colorize_code "here=<<-SQL\n\#{."
    here=<<-SQL
    #{.
    
  2. ghost closed this as completedon Sep 28, 2022
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions