ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: merch-redmine@jeremyevans.net
To: ruby-core@ruby-lang.org
Subject: [ruby-core:100908] [Ruby master Feature#17276] Ripper stops tokenizing after keyword as a method parameter
Date: Tue, 17 Nov 2020 16:07:24 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-88560.20201117160723.131@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17276.20201021100028.131@ruby-lang.org

Issue #17276 has been updated by jeremyevans0 (Jeremy Evans).


Eregon (Benoit Daloze) wrote in #note-2:
> jeremyevans0 (Jeremy Evans) wrote in #note-1:
> > Maybe we could support keyword arguments in `Ripper.lex` and `Ripper.tokenize` to raise SyntaxError for errors?  Here's a pull request for that approach: https://github.com/ruby/ruby/pull/3774
> 
> I agree it would be nice.
> 
> Do you think the same would be possible for `Ripper.sexp/sexp_raw`?

Yes, the same is possible with `Ripper.sexp/sexp_raw`.  I've updated the pull request to handle those as well.

----------------------------------------
Feature #17276: Ripper stops tokenizing after keyword as a method parameter
https://bugs.ruby-lang.org/issues/17276#change-88560

* Author: no6v (Nobuhiro IMAI)
* Status: Open
* Priority: Normal
----------------------------------------
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




-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2020-11-17 16:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-21 10:00 [ruby-core:100470] [Ruby master Bug#17276] Ripper stops tokenizing after keyword as a method parameter nov
2020-11-17  5:17 ` [ruby-core:100885] [Ruby master Feature#17276] " merch-redmine
2020-11-17 10:10 ` [ruby-core:100891] " eregontp
2020-11-17 16:07 ` merch-redmine [this message]
2020-11-19 10:55 ` [ruby-core:100943] " nov
2020-11-19 14:33 ` [ruby-core:100946] " nov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-88560.20201117160723.131@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).