From: koic.ito@gmail.com
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:51061] [Ruby master Bug#17925] Pattern matching syntax using semicolon one-line
Date: Sat, 29 May 2021 15:26:38 +0000 (UTC) [thread overview]
Message-ID: <redmine.issue-17925.20210529152637.9869@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-17925.20210529152637.9869@ruby-lang.org>
Issue #17925 has been reported by koic (Koichi ITO).
----------------------------------------
Bug #17925: Pattern matching syntax using semicolon one-line
https://bugs.ruby-lang.org/issues/17925
* Author: koic (Koichi ITO)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.0dev (2021-05-28T16:34:27Z master e56ba6231f) [x86_64-darwin19]
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
## Summary
There are the following differences between `case ... when` and` case ... in`. Is this an expected behavior?
```console
% ruby -v
ruby 3.1.0dev (2021-05-28T16:34:27Z master e56ba6231f) [x86_64-darwin19]
% ruby -ce 'case expression when 42; end'
Syntax OK
% ruby -ce 'case expression in 42; end'
-e:1: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
-e:1: syntax error, unexpected `end', expecting `when'
case expression in 42; end
```
So, I have two concerns.
- Since the pattern matching syntax is different from `case ... when`, can't user write semicolon one-line `case ... in` in the same semicolon one-line as `case ... when`?
- Does `case expression in 42; end` display an experimental warning of one-line pattern matching. Right?
This is reproduced in Ruby 3.1.0-dev and Ruby 3.0.1.
## Additional Information
NOTE 1: I understand that only syntax that doesn't use `case` and `end` is experimental one-line pattern matching syntax.
```
% ruby -ce 'expression in 42'
-e:1: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
Syntax OK
```
NOTE 2: The syntax is OK if a semicolon is used between `expression` and `in`. But `case ... when` is a valid syntax to omit.
```
% ruby -e ruby -ce 'case expression; in 42; end'
Syntax OK
```
--
https://bugs.ruby-lang.org/
next parent reply other threads:[~2021-05-29 15:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-29 15:26 koic.ito [this message]
2021-05-30 8:41 ` [ruby-dev:51062] " koic.ito
2021-06-04 15:08 ` [ruby-dev:51063] " nobu
2023-08-24 21:38 ` [ruby-dev:52040] " jeremyevans0 (Jeremy Evans) via ruby-dev
2023-08-25 3:57 ` [ruby-dev:52041] " nobu (Nobuyoshi Nakada) via ruby-dev
2023-08-25 18:16 ` [ruby-dev:52042] " kddnewton (Kevin Newton) via ruby-dev
2023-09-04 22:57 ` [ruby-dev:52043] " yui-knk (Kaneko Yuichiro) via ruby-dev
2023-09-22 13:11 ` [ruby-dev:52044] " kddnewton (Kevin Newton) via ruby-dev
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.issue-17925.20210529152637.9869@ruby-lang.org \
--to=koic.ito@gmail.com \
--cc=ruby-dev@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).