On Saturday, 3 April 2021 at 13:46:17 UTC, kdevel wrote:
Why does this code

[...]
```d
   ec.opAssign (bar (1)); // okay
// ec = bar (1); // Error: expression bar(1) is void and has no value
```
[...]

compile with the abovementioned error?

This is a compiler bug. You're not allowed to have a `void` expression on the right-hand side of an assignment, but you are allowed to pass a `void` expression to a function that takes a `lazy` parameter. Currently, the compiler checks for errors before rewriting the assignment to an `opAssign` call, which means that it will issue an error even in cases where the rewrite would have worked. What it should do instead is rewrite the assignment first, and *then* check for errors.

Reply via email to