ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "willcosgrove (Will Cosgrove) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "willcosgrove (Will Cosgrove)" <noreply@ruby-lang.org>
Subject: [ruby-core:115912] [Ruby master Bug#20090] Anonymous arguments are now syntax errors in unambiguous cases
Date: Tue, 26 Dec 2023 17:57:25 +0000 (UTC)	[thread overview]
Message-ID: <redmine.issue-20090.20231226175724.53086@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-20090.20231226175724.53086@ruby-lang.org

Issue #20090 has been reported by willcosgrove (Will Cosgrove).

----------------------------------------
Bug #20090: Anonymous arguments are now syntax errors in unambiguous cases
https://bugs.ruby-lang.org/issues/20090

* Author: willcosgrove (Will Cosgrove)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
It looks like the changes that were made in #19370 may have gone further than intended. It's also possible I'm misunderstanding what decision was made. But it was my understanding that the goal was to make ambiguous cases a syntax error. The test cases added are all testing the ambiguous cases:

```rb
assert_syntax_error("def b(&) ->(&) {c(&)} end", /anonymous block parameter is also used/)
# ...
assert_syntax_error("def b(*) ->(*) {c(*)} end", /anonymous rest parameter is also used/)
assert_syntax_error("def b(a, *) ->(*) {c(1, *)} end", /anonymous rest parameter is also used/)
assert_syntax_error("def b(*) ->(a, *) {c(*)} end", /anonymous rest parameter is also used/)
# ...
assert_syntax_error("def b(**) ->(**) {c(**)} end", /anonymous keyword rest parameter is also used/)
assert_syntax_error("def b(k:, **) ->(**) {c(k: 1, **)} end", /anonymous keyword rest parameter is also used/)
assert_syntax_error("def b(**) ->(k:, **) {c(**)} end", /anonymous keyword rest parameter is also used/)
```

However it is now also producing syntax errors in all of these cases:
```rb
def b(&) -> { c(&) } end

def b(*) -> { c(*) } end
def b(a, *) -> { c(1, *) } end
def b(*) ->(a) { c(a, *) } end

def b(**) -> { c(**) } end
def b(k:, **) -> { c(k: 1, **) } end
def b(**) ->(k:) { c(k:, **) } end
```

Again, it's possible I misunderstood the scope of the previous change. But it would be sad to lose the unambiguous case, as I've used that pattern quite a bit in my own projects.

This is my first time opening an issue here, so I apologize in advance if I've done anything non-standard.



-- 
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/postorius/lists/ruby-core.ml.ruby-lang.org/

       reply	other threads:[~2023-12-26 17:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-26 17:57 willcosgrove (Will Cosgrove) via ruby-core [this message]
2023-12-27  0:21 ` [ruby-core:115915] [Ruby master Bug#20090] Anonymous arguments are now syntax errors in unambiguous cases nobu (Nobuyoshi Nakada) via ruby-core
2024-01-04 16:15 ` [ruby-core:116010] " matheusrich (Matheus Richard) via ruby-core
2024-01-30 11:28 ` [ruby-core:116502] " naruse (Yui NARUSE) via ruby-core
2024-02-13 19:31 ` [ruby-core:116717] " eliotp123 (Eliot Partridge) via ruby-core
2024-02-27 15:57 ` [ruby-core:116971] " eliotp123 (Eliot Partridge) via ruby-core
2024-02-28  1:43 ` [ruby-core:116986] " hsbt (Hiroshi SHIBATA) via ruby-core
2024-03-14 13:03 ` [ruby-core:117166] " naruse (Yui NARUSE) 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-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.issue-20090.20231226175724.53086@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    --cc=noreply@ruby-lang.org \
    --cc=ruby-core@ml.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).