[#114774] [Ruby master Feature#19884] Make Safe Navigation Operator work on classes — "p8 (Petrik de Heus) via ruby-core" <ruby-core@...>
Issue #19884 has been reported by p8 (Petrik de Heus).
13 messages
2023/09/15
[ruby-core:114630] [Ruby master Bug#19788] Ripper returns a symbol instead of a token as operator for "::"
From:
"usa (Usaku NAKAMURA) via ruby-core" <ruby-core@...>
Date:
2023-09-05 11:18:27 UTC
List:
ruby-core #114630
Issue #19788 has been updated by usa (Usaku NAKAMURA).
Backport changed from 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED to 3.0: REQUIRED, 3.1: DONE, 3.2: REQUIRED
ruby_3_1 25cf111f0ab426cbf1539ba8da55c880117edba9 merged revision(s) 382678d4112f4afc6272244c22924d2b004274b1.
----------------------------------------
Bug #19788: Ripper returns a symbol instead of a token as operator for "::"
https://bugs.ruby-lang.org/issues/19788#change-104457
* Author: thyresias (Thierry Lambert)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mingw-ucrt]
* Backport: 3.0: REQUIRED, 3.1: DONE, 3.2: REQUIRED
----------------------------------------
```ruby
require 'ripper'
class BasicParser < Ripper
EVENTS.each do |event|
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
def on_#{event}(*args)
puts "#{event}(\#{args.inspect})"
args.unshift :#{event}
args
end
RUBY
end
end
require 'pp'
BasicParser.new('a&.b').parse
# in stdout:
# ident(["a"])
# op(["&."])
# vcall([[:ident, "a"]])
# ident(["b"])
# call([[:vcall, [:ident, "a"]], [:op, "&."], [:ident, "b"]])
BasicParser.new('a::b').parse
# in stdout:
# ident(["a"])
# op(["::"])
# vcall([[:ident, "a"]])
# ident(["b"])
# call([[:vcall, [:ident, "a"]], :"::", [:ident, "b"]])
```
On the last line, consistent with `&.`, I would have expected:
```ruby
# call([[:vcall, [:ident, "a"]], [:op, "::"], [:ident, "b"]])
```
This is true for the "operator" argument of `call`, `command_call` and `field`.
Is it intended?
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- [email protected]
To unsubscribe send an email to [email protected]
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/