* [ruby-dev:52100] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens
@ 2024-08-13 2:12 matz (Yukihiro Matsumoto) via ruby-dev
2024-08-13 13:19 ` [ruby-dev:52101] " bkuhlmann (Brooke Kuhlmann) via ruby-dev
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: matz (Yukihiro Matsumoto) via ruby-dev @ 2024-08-13 2:12 UTC (permalink / raw)
To: ruby-dev; +Cc: matz (Yukihiro Matsumoto)
Issue #20675 has been reported by matz (Yukihiro Matsumoto).
----------------------------------------
Bug #20675: Parse error with required kwargs and omitted parens
https://bugs.ruby-lang.org/issues/20675
* 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-dev:52101] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens
2024-08-13 2:12 [ruby-dev:52100] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens matz (Yukihiro Matsumoto) via ruby-dev
@ 2024-08-13 13:19 ` bkuhlmann (Brooke Kuhlmann) via ruby-dev
2024-08-14 19:27 ` [ruby-dev:52102] " Dan0042 (Daniel DeLorme) via ruby-dev
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: bkuhlmann (Brooke Kuhlmann) via ruby-dev @ 2024-08-13 13:19 UTC (permalink / raw)
To: ruby-dev; +Cc: bkuhlmann (Brooke Kuhlmann)
Issue #20675 has been updated by bkuhlmann (Brooke Kuhlmann).
I think this would be *great* and would *love* to use keyword parameters without parenthesis...but I don't know how complicated this would be for the parser (including backwards compatibility which Jeremy (Evans) has mentioned before). If this were made possible -- there is an upside -- as anonymous blocks would also benefit from this support as this is not valid syntax (currently):
``` ruby
def demo positional, &block
other positional, &block
end
```
💡 For more on this, see [Issue 18441](https://bugs.ruby-lang.org/issues/18441).
----------------------------------------
Bug #20675: Parse error with required kwargs and omitted parens
https://bugs.ruby-lang.org/issues/20675#change-109405
* 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-dev:52102] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens
2024-08-13 2:12 [ruby-dev:52100] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens 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 ` Dan0042 (Daniel DeLorme) via ruby-dev
2024-08-15 2:16 ` [ruby-dev:52103] " ko1 (Koichi Sasada) via ruby-dev
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Dan0042 (Daniel DeLorme) via ruby-dev @ 2024-08-14 19:27 UTC (permalink / raw)
To: ruby-dev; +Cc: Dan0042 (Daniel DeLorme)
Issue #20675 has been updated by Dan0042 (Daniel DeLorme).
I agree that `f k:` at end of line should be parsed as `f(k:)`. Even though it is backward incompatible, it can be detected statically, so the migration path is easy. Ruby 3.4 could output a deprecation warning at parse time. We could have a script/gem to detect if the pattern is currently used in any files, so people can check their application code. If it's used in any gems they could be flagged as incompatible with Ruby 3.5. There's a number of pain-free ways of dealing with this.
----------------------------------------
Bug #20675: Parse error with required kwargs and omitted parens
https://bugs.ruby-lang.org/issues/20675#change-109423
* 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-dev:52103] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens
2024-08-13 2:12 [ruby-dev:52100] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens 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 ` ko1 (Koichi Sasada) via ruby-dev
2024-08-15 16:04 ` [ruby-dev:52104] " Dan0042 (Daniel DeLorme) via ruby-dev
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ko1 (Koichi Sasada) via ruby-dev @ 2024-08-15 2:16 UTC (permalink / raw)
To: ruby-dev; +Cc: ko1 (Koichi Sasada)
Issue #20675 has been updated by ko1 (Koichi Sasada).
This change is compatibility issue and I counted the number of `def foo k:<newline>` patterns and I found about 4000 cases in recent gems.
https://gist.github.com/ko1/cd46d87c40df6896f2c885094133bf88
----------------------------------------
Bug #20675: Parse error with required kwargs and omitted parens
https://bugs.ruby-lang.org/issues/20675#change-109426
* 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-dev:52104] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens
2024-08-13 2:12 [ruby-dev:52100] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens matz (Yukihiro Matsumoto) via ruby-dev
` (2 preceding siblings ...)
2024-08-15 2:16 ` [ruby-dev:52103] " ko1 (Koichi Sasada) via ruby-dev
@ 2024-08-15 16:04 ` Dan0042 (Daniel DeLorme) via ruby-dev
2024-08-15 22:12 ` [ruby-dev:52105] " jeremyevans0 (Jeremy Evans) via ruby-dev
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Dan0042 (Daniel DeLorme) via ruby-dev @ 2024-08-15 16:04 UTC (permalink / raw)
To: ruby-dev; +Cc: Dan0042 (Daniel DeLorme)
Issue #20675 has been updated by Dan0042 (Daniel DeLorme).
I believe Matz was talking about changing the behavior of `f k:<newline>`, so method definition `def foo k:<newline>` would remain the same.
Although `f k:<newline>expr` would be incompatible, what about `f(k:<newline>expr)` ?
----------------------------------------
Bug #20675: Parse error with required kwargs and omitted parens
https://bugs.ruby-lang.org/issues/20675#change-109431
* 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-dev:52105] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens
2024-08-13 2:12 [ruby-dev:52100] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens matz (Yukihiro Matsumoto) via ruby-dev
` (3 preceding siblings ...)
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
2024-08-16 8:43 ` [ruby-dev:52106] " ko1 (Koichi Sasada) via ruby-dev
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jeremyevans0 (Jeremy Evans) via ruby-dev @ 2024-08-15 22:12 UTC (permalink / raw)
To: ruby-dev; +Cc: jeremyevans0 (Jeremy Evans)
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-dev:52106] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens
2024-08-13 2:12 [ruby-dev:52100] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens matz (Yukihiro Matsumoto) via ruby-dev
` (4 preceding siblings ...)
2024-08-15 22:12 ` [ruby-dev:52105] " jeremyevans0 (Jeremy Evans) via ruby-dev
@ 2024-08-16 8:43 ` 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
7 siblings, 0 replies; 9+ messages in thread
From: ko1 (Koichi Sasada) via ruby-dev @ 2024-08-16 8:43 UTC (permalink / raw)
To: ruby-dev; +Cc: ko1 (Koichi Sasada)
Issue #20675 has been updated by ko1 (Koichi Sasada).
Dan0042 (Daniel DeLorme) wrote in #note-4:
> I believe Matz was talking about changing the behavior of `f k:<newline>`, so method definition `def foo k:<newline>` would remain the same.
>
> Although `f k:<newline>expr` would be incompatible, what about `f(k:<newline>expr)` ?
for `f k:<newline>val`, I found about 500 cases.
https://gist.github.com/ko1/e15fd4959675db07188e7a67ddc1c2c6
----------------------------------------
Bug #20675: Parse error with required kwargs and omitted parens
https://bugs.ruby-lang.org/issues/20675#change-109433
* 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-dev:52107] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens
2024-08-13 2:12 [ruby-dev:52100] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens matz (Yukihiro Matsumoto) via ruby-dev
` (5 preceding siblings ...)
2024-08-16 8:43 ` [ruby-dev:52106] " ko1 (Koichi Sasada) via ruby-dev
@ 2024-08-16 12:52 ` Dan0042 (Daniel DeLorme) via ruby-dev
2024-09-05 5:56 ` [ruby-dev:52111] " matz (Yukihiro Matsumoto) via ruby-dev
7 siblings, 0 replies; 9+ messages in thread
From: Dan0042 (Daniel DeLorme) via ruby-dev @ 2024-08-16 12:52 UTC (permalink / raw)
To: ruby-dev; +Cc: Dan0042 (Daniel DeLorme)
Issue #20675 has been updated by Dan0042 (Daniel DeLorme).
> for `f k:<newline>val`, I found about 500 cases.
Thank you for searching. That's a lot more than I was able to find in my 950 sample gems, and with such a number I would vote to not change anything.
----------------------------------------
Bug #20675: Parse error with required kwargs and omitted parens
https://bugs.ruby-lang.org/issues/20675#change-109434
* 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-dev:52111] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens
2024-08-13 2:12 [ruby-dev:52100] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens matz (Yukihiro Matsumoto) via ruby-dev
` (6 preceding siblings ...)
2024-08-16 12:52 ` [ruby-dev:52107] " Dan0042 (Daniel DeLorme) via ruby-dev
@ 2024-09-05 5:56 ` matz (Yukihiro Matsumoto) via ruby-dev
7 siblings, 0 replies; 9+ messages in thread
From: matz (Yukihiro Matsumoto) via ruby-dev @ 2024-09-05 5:56 UTC (permalink / raw)
To: ruby-dev; +Cc: matz (Yukihiro Matsumoto)
Issue #20675 has been updated by matz (Yukihiro Matsumoto).
Status changed from Open to Closed
OK, I understand the reason and background of this behavior. The issue is withdrawn.
Matz.
----------------------------------------
Bug #20675: Parse error with required kwargs and omitted parens
https://bugs.ruby-lang.org/issues/20675#change-109632
* Author: matz (Yukihiro Matsumoto)
* Status: Closed
* 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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-09-05 5:56 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-13 2:12 [ruby-dev:52100] [Ruby master Bug#20675] Parse error with required kwargs and omitted parens 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 ` [ruby-dev:52105] " jeremyevans0 (Jeremy Evans) via ruby-dev
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
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).