My Little Dustmite: Bisect is Magic

Ethan gooberman at gmail.com
Sat Jul 27 11:24:11 UTC 2019


On Saturday, 27 July 2019 at 09:14:54 UTC, Kagamin wrote:
> Isn't your complaint that the assert is not helpful?

No, the complaint is that DMD withheld error information in favor 
of my static assert.

> If it was helpful and told exactly what you need to do, why do 
> you need to remove it and debug?

Because DMD withheld error information in favor of my static 
assert.

So. Since I clearly didn't contextualise this properly.

The static assert itself is in a mixin template. It is used in 
four objects currently - two different kinds of clients, and the 
server receivers that limit what they can do.

This is why the static assert was added in the first place - an 
error would happen, DMD would report the error location as being 
inside a mixin without context as to where the mixin was invoked, 
and I'd be left wondering which part of my code I overlooked this 
time.

Messages themselves are implemented in a mixin template. Mix them 
all in to the same class.

Normally, these messages will compile, throw the error, and then 
the static assert will tell you the handy information.

In this case, I wasn't getting the error messages and no idea of 
why the static assert was firing.

This just plain appears to be a static assert problem in general. 
Probably by design, except the spec doesn't mention that static 
assert is dependent on scope resolution order. Here's an example 
without templates that illustrates what I'm referring to. Move 
the static assert inside main() and you get the behavior I was 
expecting.

https://run.dlang.io/is/rjTRks

--

void broken()
{
     doesntexist();
}

int main( string[] args )
{
     broken();
}

static assert( false, "so here's a static assert" );


More information about the Digitalmars-d mailing list