Error: expression `update` of type `void` does not have a boolean value

Josphe Brigmo JospheBrigmo at gmail.com
Sat Sep 8 06:56:40 UTC 2018


On Saturday, 8 September 2018 at 05:39:39 UTC, Alex wrote:
> On Saturday, 8 September 2018 at 03:12:56 UTC, Josphe Brigmo 
> wrote:
>> auto foo(bool update = false)()
>> {
>>     static if(update)
>>     { }
>> }
>>
>> and the compiler, after upgrading to 2.082 from 2.080 now says:
>>
>> Error: expression `update` of type `void` does not have a 
>> boolean value
>>
>> when update is clearly a bool.
>>
>> Why the hell is the compiler now thinking update is a void?
>>
>> 1. This code compiles fine in a test app and 2. when I rename 
>> update to something else it works fine.
>>
>> 2. There is no other use of update in the entire module(not 
>> that it should matter)
>>
>> Seems this is a compiler bug but only has a problem in 
>> context. Remember, it worked find before I updated dmd and 
>> there is no reason why it shouldn't work.
>
> Could you show some more code, as this works for me:
>
> ´´´
> import std.stdio;
>
> void main()
> {
> 	foo;
> }
>
> auto foo(bool update = false)()
> {
> 	static if(update)
> 	{
>
> 	}
> }
> ´´´
>
> compiled with
> dmd --version
> DMD64 D Compiler v2.082.0
> Copyright (C) 1999-2018 by The D Language Foundation, All 
> Rights Reserved written by Walter Bright
>
> dmd ./source/app.d
>
> used on a Mac with Darwin Kernel Version 17.7.0

I can't, the code is from a very large project and it's too 
intertwined.

I already said it worked in simple form and that it worked with a 
previous compiler, so this is a regression.

Changing no code and only swapping compilers produces this bug...

and as you can see, it's obviously a bug given the form of the 
function and the error message and that it worked before without 
changes.

Why the specific term update? I don't know.

My project does not use the term update at all in any other 
context except that one. But I did find:

void update(K, V, C, U)(ref V[K] aa, K key, scope C create, scope 
U update)









More information about the Digitalmars-d-learn mailing list