Libdparse needs to be updated to recognize AliasAssign declarations

Paul Backus snarwin at gmail.com
Tue May 4 14:12:28 UTC 2021


On Tuesday, 4 May 2021 at 14:07:47 UTC, WebFreak001 wrote:
> however what about this code?
> ```d
> void foo() {
>     alias A = B;
>     A = C;
> }
> ```
>
> is the `A = C` in this case an AliasAssign? how would the 
> parser differentiate between this AliasAssign and regular 
> assignments?

AliasAssign is only allowed in declaration contexts--the top 
level of a module, or the body of a `struct`, `class`, 
`template`, etc. In these contexts, a normal assignment statement 
is not allowed, so there is no ambiguity.

Personally I think this is kind of a hack, and would have 
preferred a separate "rebind" operator to disambiguate (maybe 
`:=`). But this is the solution Walter decided on.


More information about the Digitalmars-d mailing list