Issue #22177 has been reported by shugo (Shugo Maeda). ---------------------------------------- Bug #22177: Prism rejects a nested destructuring target in a for loop index, while parse.y accepts it https://bugs.ruby-lang.org/issues/22177 * Author: shugo (Shugo Maeda) * Status: Open * ruby -v: ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +PRISM [x86_64-linux] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ## Summary When the index of a `for` loop is a multiple-assignment target whose first element is itself a parenthesized target (for example `(a, b), c`), Prism reports a syntax error, but parse.y accepts it. The same target works in a normal multiple assignment in both parsers, so the difference is specific to the `for` loop index. ## Reproduction ```ruby for (a, b), c in [[[1, 2], 3]] do p [a, b, c] end ``` ### parse.y (--parser=parse.y) Accepted. Prints: ``` [1, 2, 3] ``` ### Prism (default, --parser=prism) Rejected: ```
1 | for (a, b), c in [[[1, 2], 3]] do | ^~~~~ unexpected write target
--
https://bugs.ruby-lang.org/