From: "shugo (Shugo Maeda) via ruby-core" Date: 2026-07-04T14:58:11+00:00 Subject: [ruby-core:125928] [Ruby Bug#22177] Prism rejects a nested destructuring target in a for loop index, while parse.y accepts it Issue #22177 has been updated by shugo (Shugo Maeda). Assignee set to prism I've created a pull request: https://github.com/ruby/prism/pull/4156 ---------------------------------------- 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#change-117896 * Author: shugo (Shugo Maeda) * Status: Open * Assignee: prism * 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/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/