Project

General

Profile

Actions

Feature #21875

open

Handling of trailing commas in lambda parameters

Feature #21875: Handling of trailing commas in lambda parameters

Added by Earlopain (Earlopain _) 10 days ago. Updated 10 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:124797]

Description

https://bugs.ruby-lang.org/issues/19107 was accepted, which is about trailing commands in method definitions.

lambdas were not explicitly mentioned but I wanted to confirm how they should behave with a trailing comma. Or if a trailing comma should even be accepted for them.

It's not clear to me since lambdas sometimes behave like blocks and sometimes more like methods. ->(...) {} for example is syntax invalid (same as in blocks) but they do check their arity with blocks don't do.

If a trailing comma is accepted it can either

  • be implicit splat like in foo do |bar,|; end or foo do |bar|; end. It would also mean that the trailing comma is only allowed after a positional argument.
  • Just be ignored and be accepted in most places like for method definitions.

The first option would be rather useless in regards to https://bugs.ruby-lang.org/issues/19107 when you just want to add the comma for cleaner diffs. But I guess for lambdas this happens very rarely anyways.


Related issues 1 (0 open1 closed)

Related to Ruby - Feature #19107: Allow trailing comma in method signatureClosedprismActions
Actions

Also available in: PDF Atom