[ruby-core:109667] [Ruby master Bug#18883] parse.y: trailing comma cannot coexist with star
From:
"jeremyevans0 (Jeremy Evans)" <noreply@...>
Date:
2022-08-24 19:14:02 UTC
List:
ruby-core #109667
Issue #18883 has been updated by jeremyevans0 (Jeremy Evans). Status changed from Open to Rejected After giving this some more thought, I am fairly sure this is not a bug, and I'm rejecting this. @zverok is correct, a trailing comma is an implicit splat, and you cannot have multiple splats in a multiple assignment, so a syntax error is the correct behavior in this case. ---------------------------------------- Bug #18883: parse.y: trailing comma cannot coexist with star https://bugs.ruby-lang.org/issues/18883#change-98889 * Author: qnighy (Masaki Hara) * Status: Rejected * Priority: Normal * ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- The following code is a syntax error: ```ruby *x, y, = 1, 2 # syntax error, unexpected '=' ``` although the following: ```ruby 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. -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>