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

Iain Buclaw <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #6 from Iain Buclaw <[email protected]> ---
Supplementary test for this issue.
---
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`
}
---

This happens because op_overload is recursive, i.e:

op_overload(e=`s1 = true`, ad1=`S1`)
-> op_overload(e=`s1.entry()`, ad1=`EntryType`)
  -> check: EntryType.members == 1 && typeof(EntryType[0]) == typeof(true)
    -> TRUE: return e=`s1.entry()._state = true`
-> check: S1.members == 1 && typeof(S1[0]) == typeof(true)
  -> FALSE: deprecation warning

--

Reply via email to