Project

General

Profile

Actions

Feature #17276

closed

Ripper stops tokenizing after keyword as a method parameter

Added by no6v (Nobuhiro IMAI) about 4 years ago. Updated about 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:100470]

Description

Although these are obviously syntax errors at this time, the following
codes cannot be tokenized correctly by Ripper.tokenize.

$ cat src.rb
def req(true) end
def opt(true=0) end
def rest(*true) end
def keyrest(**true) end
def block(&true) end
->true{}
->true=0{}
->*true{}
->**true{}
->&true{}
$ ruby -rripper -vlne 'p Ripper.tokenize($_)' src.rb
ruby 3.0.0dev (2020-10-21T00:24:47Z master da25affdac) [x86_64-linux]
["def", " ", "req", "(", "true", ")"]
["def", " ", "opt", "(", "true", "=", "0", ")"]
["def", " ", "rest", "(", "*", "true", ")"]
["def", " ", "keyrest", "(", "**", "true", ")"]
["def", " ", "block", "(", "&", "true", ")"]
["->", "true", "{"]
["->", "true", "=", "0", "{"]
["->", "*", "true", "{"]
["->", "**", "true", "{"]
["->", "&", "true", "{"]

end and } are not shown in result.

This seems to prevent irb from determining the continuity of the input.
See: https://github.com/ruby/irb/issues/38

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0