Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ntrel
Copy link

@ntrel ntrel commented Nov 14, 2025

Support:

    int b;
    (auto a, b) = (1, 2);
    ...
    int a, b, c;
    ((a, b), c) = ((1, 2), 3);

See also #12 (comment).

Ban enum/static components.
Extend fail_compilation/unpack_semantic.d test.

Ban enum/static components.
@tgehr
Copy link
Owner

tgehr commented Nov 14, 2025

Looks good to me for what it does, though I guess ( (a, b) ) = (1, 2) and mixin("(a, b)") = (1, 2) still lower to tuple(a, b).opAssign(tuple(1,2)) and (c ? (a, b) : (b, a)) = (1, 2) still lowers to (c ? tuple(a, b) : tuple(b, a)).opAssign(tuple(1, 2)).

Somehow it would be nice if it either worked or errored out, though I am not sure what's the best way to go about that.

@ntrel
Copy link
Author

ntrel commented Nov 15, 2025

Perhaps I could merge TupleLiteralExp and UnpackExp and handle this pull's UnpackExp lowering inside AssignExp semantic - that could handle the mixin/parens cases and possibly the conditional one too. There could be a flag allowDeclarations which is set when an ExpStatement contains an AssignExp whose left-hand side is a TupleLiteralExp. Merging the expressions would also allow non-declaration unpacking in an AssignExp which is a sub-expression of another expression.

Anyway I'll set this pull as ready for the record.

@ntrel ntrel marked this pull request as ready for review November 15, 2025 12:07
@tgehr tgehr merged commit 919bfb7 into tgehr:tuple-syntax Nov 15, 2025
15 checks passed
@ntrel ntrel deleted the unpack-exp2 branch November 16, 2025 20:36
@ntrel ntrel restored the unpack-exp2 branch November 16, 2025 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants