Libdparse needs to be updated to recognize AliasAssign declarations

WebFreak001 d.forum at webfreak.org
Tue May 4 14:18:33 UTC 2021


On Tuesday, 4 May 2021 at 14:12:28 UTC, Paul Backus wrote:
> 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.

in that case that will make it easy to add it to libdparse


More information about the Digitalmars-d mailing list