Project

General

Profile

Actions

Bug #18883

closed

parse.y: trailing comma cannot coexist with star

Added by qnighy (Masaki Hara) over 2 years ago. Updated about 2 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
[ruby-core:109077]

Description

The following code is a syntax error:

*x, y, = 1, 2 # syntax error, unexpected '='

although the following:

x, y = 1, 2  # OK
x, y, = 1, 2 # OK
*x, y = 1, 2 # OK
# *x, y, = 1, 2

In my understanding, the trailing comma does nothing unless the lhs becomes otherwise a single assignment.

Therefore it is natural to allow the trailing comma whether * exists or not.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0