opendlang / opend

Boost Software License 1.0
84 stars 18 forks source link

Unpacking: do not require storage classes if type is specified. #78

Closed tgehr closed 1 week ago

tgehr commented 1 week ago

As mojo pointed out in discord:

@tg I am just referencing the DIP idea post:

    Types can be declared explicitly, or inferred, independently for each variable:

(int a, (string b, auto c)) = t(1, t("2", 3.0f));

but in my tests:

auto foo() => t(1, 2);
(int a, int b) = foo(); 

test_01.d(21): Error: unpacked variables need at least one storage class, did you mean `auto a`?
test_01.d(21): Error: unpacked variables need at least one storage class, did you mean `auto b`?

This works:

( auto a, auto b) = foo;

This fixes that issue.