Thread overview
[Issue 17703] __traits(compiles, AssignmentExpression) no longer compiles without surrounding parens
Aug 03, 2017
Martin Nowak
[Issue 17703] __traits(compiles, a[] = b[]) generates errors without surrounding parentheses
Dec 17, 2022
Iain Buclaw
August 03, 2017
https://issues.dlang.org/show_bug.cgi?id=17703

Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code@dawg.eu
           Severity|regression                  |normal

--- Comment #1 from Martin Nowak <code@dawg.eu> ---
Looks like the assignment expression parsing isn't fully working, below example works.

void works(int a, int b)
{
    static assert(__traits(compiles, a = b));
}

Also the specs support the case http://dlang.org/spec/grammar.html#TraitsArgument

I went back until 2.050 and it still wouldn't accept the code, downgrading to a normal bug.

Simple workaround:

  __traits(compiles, { exp; })

--
November 30, 2018
https://issues.dlang.org/show_bug.cgi?id=17703

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com
            Summary|__traits(compiles,          |__traits(compiles, a[] =
                   |AssignmentExpression) no    |b[]) generates errors
                   |longer compiles without     |without surrounding
                   |surrounding parens          |parentheses

--- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> ---
Just ran into this too.

--
November 30, 2018
https://issues.dlang.org/show_bug.cgi?id=17703

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=17703

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--