From 2315b01ae691e5e9e54fdfdfb4642c8fbc559e48 Mon Sep 17 00:00:00 2001 From: metagn Date: Tue, 28 Mar 2023 18:52:23 +0300 Subject: tuple unpacking for vars as just sugar, allowing nesting (#21563) * tuple unpacking for vars as just sugar, allowing nesting * set temp symbol AST * hopeful fix some issues, add test for #19364 * always use temp for consts * document, fix small issue * fix manual indentation * actually fix manual * use helper proc * don't resem temp tuple assignment --- changelogs/changelog_2_0_0.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'changelogs') diff --git a/changelogs/changelog_2_0_0.md b/changelogs/changelog_2_0_0.md index cbe755478..19d97b769 100644 --- a/changelogs/changelog_2_0_0.md +++ b/changelogs/changelog_2_0_0.md @@ -343,6 +343,26 @@ - `=wasMoved` can be overridden by users. +- Tuple unpacking for variables is now treated as syntax sugar that directly + expands into multiple assignments. Along with this, tuple unpacking for + variables can now be nested. + + ```nim + proc returnsNestedTuple(): (int, (int, int), int, int) = (4, (5, 7), 2, 3) + + let (x, (_, y), _, z) = returnsNestedTuple() + # roughly becomes + let + tmpTup1 = returnsNestedTuple() + x = tmpTup1[0] + tmpTup2 = tmpTup1[1] + y = tmpTup2[1] + z = tmpTup1[3] + ``` + + As a result `nnkVarTuple` nodes in variable sections will no longer be + reflected in `typed` AST. + ## Compiler changes - The `gc` switch has been renamed to `mm` ("memory management") in order to reflect the -- cgit 1.4.1-2-gfad0