From: "Dan0042 (Daniel DeLorme) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "Dan0042 (Daniel DeLorme)" <noreply@ruby-lang.org>
Subject: [ruby-core:119467] [Ruby master Bug#20785] Should `a in b, and c` `a in b, or c` `a in b, rescue c` be syntax ok?
Date: Sun, 06 Oct 2024 00:55:45 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-110085.20241006005545.10330@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-20785.20241005074708.10330@ruby-lang.org>
Issue #20785 has been updated by Dan0042 (Daniel DeLorme).
tompng (tomoya ishida) wrote:
> I think these should be accepted like parse.y (prism rejects)
> ~~~ruby
> tap do
> a in b,
> end
>
> tap do
> a in b,
> rescue
> end
> ~~~
Can you explain your reasoning here? I'm guessing that `a in b,` is parsed as `a in [b,]` but a trailing comma like that is just too wild for me; it totally breaks my intuitions about Ruby syntax, and I think it should be rejected.
----------------------------------------
Bug #20785: Should `a in b, and c` `a in b, or c` `a in b, rescue c` be syntax ok?
https://bugs.ruby-lang.org/issues/20785#change-110085
* Author: tompng (tomoya ishida)
* Status: Open
* Assignee: ktsj (Kazuki Tsujimoto)
* ruby -v: ruby 3.4.0dev (2024-10-04T03:22:53Z master 939ec9f080) +YJIT +MN +PRISM [arm64-darwin22]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
This code is accepted in parse.y but rejected in prism
~~~ruby
tap do
a in b, and c
a in b, or c
a in b, rescue c
end
# parsed as
tap do
(a in b,;) and c
(a in b,;) or c
a in b,;
rescue c
end
~~~
I think these should be rejected like prism (parse.y accepts)
~~~ruby
a in b, and c
a in b,
and c
tap do
a in b, rescue c
end
~~~
I think these should be accepted like parse.y (prism rejects)
~~~ruby
tap do
a in b,
end
tap do
a in b,
rescue
end
~~~
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
next prev parent reply other threads:[~2024-10-06 0:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-05 7:47 [ruby-core:119462] " tompng (tomoya ishida) via ruby-core
2024-10-05 14:25 ` [ruby-core:119463] " nobu (Nobuyoshi Nakada) via ruby-core
2024-10-05 14:27 ` [ruby-core:119464] " nobu (Nobuyoshi Nakada) via ruby-core
2024-10-06 0:55 ` Dan0042 (Daniel DeLorme) via ruby-core [this message]
2024-10-06 4:07 ` [ruby-core:119468] " ktsj (Kazuki Tsujimoto) via ruby-core
2024-11-07 10:34 ` [ruby-core:119802] " mame (Yusuke Endoh) via ruby-core
2024-11-08 15:44 ` [ruby-core:119844] " kddnewton (Kevin Newton) via ruby-core
2024-11-13 13:14 ` [ruby-core:119914] " Dan0042 (Daniel DeLorme) via ruby-core
2024-11-13 13:39 ` [ruby-core:119916] " Eregon (Benoit Daloze) via ruby-core
2024-11-16 6:05 ` [ruby-core:119946] " mame (Yusuke Endoh) via ruby-core
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-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-110085.20241006005545.10330@ruby-lang.org \
--to=ruby-core@ml.ruby-lang.org \
--cc=noreply@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 NNTP newsgroup(s).