From: nov@... Date: 2020-12-14T17:18:21+00:00 Subject: [ruby-core:101449] [Ruby master Bug#17345] ripper: nothing raised when assigning to keyword variables Issue #17345 has been updated by no6v (Nobuhiro IMAI). no6v (Nobuhiro IMAI) wrote in #note-2: > Thanks for the quick fix, however `*_error` parser events except `parse_error` seem not to set an error message properly. > > ``` > $ ruby -rripper -ve 'Ripper.lex("nil=1", raise_errors: true)' > ruby 3.0.0dev (2020-11-26T11:14:34Z master f5ca3ff4db) [x86_64-linux] > /home/nov/.rvm/rubies/ruby-head/lib/ruby/3.0.0/ripper/lexer.rb:134:in `parse': # ;# ;# (SyntaxError) > ``` Won't to fix this? This breaks `irb --colorize` which uses `Ripper::Lexer#scan` and which expects `Ripper::Lexer::Elem#message` to return a string. https://github.com/ruby/ruby/blob/master/lib/irb/color.rb#L161-L163 While typing `nil=`, the following exception raises immediately on pressing `=` key. ``` $ docker run --rm -it rubylang/all-ruby:latest ./bin/ruby-3.0.0-preview2 -rirb -eIRB.start irb(main):001:0> nil/build-all-ruby/3.0.0-preview2/lib/ruby/3.0.0/irb/color.rb:163:in `block (2 levels) in scan': no implicit conversion of Array into String (TypeError) ... ``` ---------------------------------------- Bug #17345: ripper: nothing raised when assigning to keyword variables https://bugs.ruby-lang.org/issues/17345#change-89219 * Author: no6v (Nobuhiro IMAI) * Status: Closed * Priority: Normal * ruby -v: ruby 3.0.0dev (2020-11-25T04:36:39Z master 00f046ef57) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- ```ruby require "ripper" Ripper.tokenize("retry=1", raise_errors: true) # => SyntaxError (syntax error, unexpected '=', expecting end-of-input) Ripper.tokenize("nil=1", raise_errors: true) # => ["nil", "=", "1"] lexer = Ripper::Lexer.new("nil=1") lexer.tokenize # => ["nil", "=", "1"] lexer.error? # => true lexer.errors # => [] ``` Lexer recognizes there was an error, but nothing is set to `errors`. -- https://bugs.ruby-lang.org/ Unsubscribe: