February 14, 2019
https://issues.dlang.org/show_bug.cgi?id=19441

--- Comment #11 from Eyal <eyal@weka.io> ---
It's not fine if only LHS side uses it and causes a partial assignment. x = y should assign whole of x. If "alias this" exists in x but it still assigns the whole of x, that's fine.

--
February 19, 2019
https://issues.dlang.org/show_bug.cgi?id=19441

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #12 from Dlang Bot <dlang-bot@dlang.rocks> ---
@RazvanN7 updated dlang/dmd pull request #9323 "Fix Issue 19441 - alias this causes partial assignment" fixing this issue:

- Fix Issue 19441 - alias this causes partial assignment

https://github.com/dlang/dmd/pull/9323

--
February 26, 2019
https://issues.dlang.org/show_bug.cgi?id=19441

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #13 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #9323 "Fix Issue 19441 - alias this causes partial assignment" was merged into master:

- e786795f3f5b059a1e8bfcb09556640ff8c096e1 by RazvanN7:
  Fix Issue 19441 - alias this causes partial assignment

https://github.com/dlang/dmd/pull/9323

--
July 21, 2019
https://issues.dlang.org/show_bug.cgi?id=19441

johanengelen@weka.io changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johanengelen@weka.io

--- Comment #14 from johanengelen@weka.io ---
How are things now supposed to work with wrapper structs? (or is that functionality now no longer available?)

```
EntryType arr;
auto getPtr() { return &arr; }

struct EntryType {
    //int somethingelse; // add for different error message
    bool _state;
    alias _state this;
}

struct S1 {
    @property auto ref entry() { return *getPtr(); }
    alias entry this;
}

void main(){
    S1 s1;
    s1 = true; // Deprecation: Cannot use `alias this` to partially initialize
               // variable `s1` of type `S1`. Use `s1.entry()._state`
}
```

Note that S1 does not store any state. The goal is to use S1 as a transparant wrapper towards some other data structure.

Weka has the kind of code of the testcase, @Eyal how do you think one should implement this after this language change?

--
July 21, 2019
https://issues.dlang.org/show_bug.cgi?id=19441

--- Comment #15 from johanengelen@weka.io ---
Answering myself: use opAssign.

--
July 21, 2019
https://issues.dlang.org/show_bug.cgi?id=19441

--- Comment #16 from johanengelen@weka.io ---
The code of my testcase should now be (with explicit opAssign):
```
EntryType arr;
auto getPtr() { return &arr; }

struct EntryType {
    int somethingelse;
    bool _state;
    void opAssign(typeof(_state) rhs) {
        _state = rhs;
    }
    alias _state this;
}

struct S1 {
    @property auto ref entry() { return *getPtr(); }
    void opAssign(bool rhs) {
        entry() = rhs;
    }
    alias entry this;
}

void main(){
    S1 s1;
    s1 = true;
}
```

Learnings:
- write to `alias this` only allowed when fully overwriting the struct _itself_
- write to only part of struct: use opAssign
- write to other data than struct itself: use opAssign

--
March 02, 2021
https://issues.dlang.org/show_bug.cgi?id=19441

anonymous4 <dfj1esp02@sneakemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pro.mathias.lang@gmail.com

--- Comment #17 from anonymous4 <dfj1esp02@sneakemail.com> ---
*** Issue 21674 has been marked as a duplicate of this issue. ***

--
1 2
Next ›   Last »