Actions
Bug #20090
closedAnonymous arguments are now syntax errors in unambiguous cases
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
Description
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:
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:
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.
Actions
Like6
Like0Like0Like5Like0Like3Like1Like2Like3