Thread overview
[Issue 19117] Alias this messes up call to normal function
Jul 26, 2018
RazvanN
[Issue 19117] Alias this incorrectly invoked in conversion to ref
Jul 26, 2018
Simen Kjaeraas
Dec 17, 2022
Iain Buclaw
July 26, 2018
https://issues.dlang.org/show_bug.cgi?id=19117

--- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> ---
(In reply to RazvanN from comment #0)
> struct A
> {
>     immutable(A) fun() { return  immutable A(); }
>     ref A fun2(ref A a)  { return this; }
> 
> 
>     alias fun this;    // line 6
> }
> 
> void main()
> {
>     A a, b;
>     b.fun2(a);
> }
> 
> aliasthisbug.d(12): Error: function aliasthisbug.A.fun2(ref A a) is not
> callable using argument types (A)
> aliasthisbug.d(12):        cannot pass argument a of type A to parameter ref
> A a
> 
> Comment line 6 an the error disappears.

Also, changing the signature of fun2 to : ref A fun2(A a) makes the example
compile

--
July 26, 2018
https://issues.dlang.org/show_bug.cgi?id=19117

Simen Kjaeraas <simen.kjaras@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras@gmail.com
            Summary|Alias this messes up call   |Alias this incorrectly
                   |to normal function          |invoked in conversion to
                   |                            |ref

--- Comment #2 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
Further simplified:

struct A {
    const(A) fun();
    alias fun this;
}

void fun2(ref A a);

unittest {
    A a;
    fun2(a);
}

This bug triggers when the alias this type is a qualified version of A (shared,
const, or immutable), and A has no aliasing (pointers, dynamic arrays, AAs).

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=19117

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 13
https://issues.dlang.org/show_bug.cgi?id=19117

--- Comment #3 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19466

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--