class A { int x; } A a; assert(!__traits(compiles, a.x = 5));
TDPL book and __traits(compiles...) snippet
Tony via Digitalmars-d-learn Sat, 10 Jul 2021 20:36:10 -0700
In section 6.2 of The D Programming Language it talks about how
the compiler will try and tell if you are going to use a null
reference. It gives this code snippet below to demonstrate that.
But with DMD v2.096.1-dirty I am getting that the compiler thinks
the code is OK. With a "!" the assert fails.