www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21802] New: opAssign and opOpAssign treat lazy void

https://issues.dlang.org/show_bug.cgi?id=21802

          Issue ID: 21802
           Summary: opAssign and opOpAssign treat lazy void parameters
                    inconsistently
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: thomas.bockman gmail.com

This used to work up through 2.061:

//////////////////////////////////
module app;

struct A {
    auto opAssign(lazy void foo) {
        foo(); }
    auto opOpAssign(string op)(lazy void foo) {
        foo(); }
}

void bar(int x) { }

void main () {
    A a;
    a ~= bar (1); // OK
    a = bar (1); // Error: expression bar(1) is void and has no value
}
//////////////////////////////////

(Inspired by this forum discussion:
https://forum.dlang.org/post/ihsyagkqntidnglxoxlq forum.dlang.org)

--
Apr 05 2021