Inconsistent behaviour static assert directly or via mixin?

DLearner bmqazwsx123 at gmail.com
Mon Mar 23 19:32:47 UTC 2026


On Monday, 23 March 2026 at 18:14:45 UTC, Julian Fondren wrote:
> On Monday, 23 March 2026 at 18:06:35 UTC, DLearner wrote:
>> If run, produces 'Indirect' message _and nothing else_.
>>
>> Now remove the '//', get 'Direct' message _and code dump_.
>>
>> Inconsistent behaviour?
>
> I don't get a code dump from either with ldc2. With gdc, 
> there's only this extra output:
>
> ```
>    12 |     static assert(false, "Direct");
>       |     ^
> ```
>
> In both cases the indirect error is reported as coming from a 
> temporary file, probably that file doesn't exist by the time 
> this extra output is sought.

DMD v2.111.0

```
test.d-mixin-14(14): Error: static assert:  "Indirect"
```

```
test.d(12): Error: static assert:  "Direct"
    static assert(false, "Direct");
    ^
```



v2.112.0


```
test.d-mixin-14(14): Error: static assert:  "Indirect"
static assert(false, "Indirect");
^
```

```

test.d(12): Error: static assert:  "Direct"
    static assert(false, "Direct");
    ^
```

I was using 2.111.0 for other reasons, and the first of the four 
outputs above is the effect sought.
Dumping the code line seems redundant (and untidy).


More information about the Digitalmars-d-learn mailing list