From: "jeremyevans0 (Jeremy Evans) via ruby-dev" <ruby-dev@ml.ruby-lang.org>
To: ruby-dev@ml.ruby-lang.org
Cc: "jeremyevans0 (Jeremy Evans)" <noreply@ruby-lang.org>
Subject: [ruby-dev:52105] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens
Date: Thu, 15 Aug 2024 22:12:33 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-109432.20240815221232.13@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-20675.20240813021248.13@ruby-lang.org>
Issue #20675 has been updated by jeremyevans0 (Jeremy Evans).
The reason for this inconsistency is backwards compatibility, so as not to break existing code when omitted hash value support was added in Ruby 3.1.
There is historical precedence for breaking backwards compatibility for a very similar case. In this example:
```ruby
def foo arg:
123
arg
end
foo
# Ruby < 2.0: SyntaxError
# Ruby 2.0: 123
# Ruby >= 2.1: ArgumentError, missing keyword: arg
```
There was no deprecation warning for the change in 2.1. I think if we want to change behavior for `foo arg:<newline>value` from `foo(arg: value)` to `foo(arg:); value`, we should add a deprecation warning in 3.4, and then change the behavior in 3.5.
----------------------------------------
Bug #20675: Parse error with required kwargs and omitted parens
https://bugs.ruby-lang.org/issues/20675#change-109432
* Author: matz (Yukihiro Matsumoto)
* Status: Open
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
As pointed out in https://github.com/mruby/mruby/issues/6268, keyword arguments without surrounding parens are a bit confusing, e.g.
```ruby
def foo arg:
123
end
```
is parsed as
```ruby
def foo(arg:)
123
end
```
where
```ruby
k=25
f k:
10
```
is parserd as
```ruby
k=25
f(k: 10)
```
In summary, should we ignore newlines after keyword labels? Should we make them behave consistent?
Matz.
--
https://bugs.ruby-lang.org/
_______________________________________________
ruby-dev mailing list -- ruby-dev@ml.ruby-lang.org
To unsubscribe send an email to ruby-dev-leave@ml.ruby-lang.org
next prev parent reply other threads:[~2024-08-15 22:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 2:12 [ruby-dev:52100] " matz (Yukihiro Matsumoto) via ruby-dev
2024-08-13 13:19 ` [ruby-dev:52101] " bkuhlmann (Brooke Kuhlmann) via ruby-dev
2024-08-14 19:27 ` [ruby-dev:52102] " Dan0042 (Daniel DeLorme) via ruby-dev
2024-08-15 2:16 ` [ruby-dev:52103] " ko1 (Koichi Sasada) via ruby-dev
2024-08-15 16:04 ` [ruby-dev:52104] " Dan0042 (Daniel DeLorme) via ruby-dev
2024-08-15 22:12 ` jeremyevans0 (Jeremy Evans) via ruby-dev [this message]
2024-08-16 8:43 ` [ruby-dev:52106] " ko1 (Koichi Sasada) via ruby-dev
2024-08-16 12:52 ` [ruby-dev:52107] " Dan0042 (Daniel DeLorme) via ruby-dev
2024-09-05 5:56 ` [ruby-dev:52111] " matz (Yukihiro Matsumoto) 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.journal-109432.20240815221232.13@ruby-lang.org \
--to=ruby-dev@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).