Jump to page: 1 2
Thread overview
[Issue 3332] Mixin a constructor with a construct already present fails
Aug 02, 2014
Vlad Levenfeld
Aug 02, 2014
Vlad Levenfeld
Oct 10, 2019
RazvanN
Sep 17, 2020
Simen Kjaeraas
Sep 17, 2020
Simen Kjaeraas
Sep 17, 2020
Simen Kjaeraas
Nov 16, 2022
RazvanN
Nov 16, 2022
Dlang Bot
Dec 17, 2022
Iain Buclaw
Apr 18, 2023
RazvanN
August 02, 2014
https://issues.dlang.org/show_bug.cgi?id=3332

Vlad Levenfeld <vlevenfeld@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vlevenfeld@gmail.com

--
August 02, 2014
https://issues.dlang.org/show_bug.cgi?id=3332

--- Comment #7 from Vlad Levenfeld <vlevenfeld@gmail.com> ---
This one bit me recently as well. I also think it would be handy to be able to control a mixin's interaction with the overload set. I have a case where I'd like to add a specialization to a mixed-in constructor set.

--
June 09, 2015
https://issues.dlang.org/show_bug.cgi?id=3332

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|D1 & D2                     |D2

--
October 10, 2019
https://issues.dlang.org/show_bug.cgi?id=3332

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #8 from RazvanN <razvan.nitu1305@gmail.com> ---
For a normal function, the mixin can be named as explicitly inserted in the overload set:

template C ()
{
    void fun(int i)
    {

    }
}

class A
{
    mixin C f;
    alias fun = f.fun;

    void fun ()
    {

    }
}

void main ()
{
    auto a = new A();
    a.fun();
}

However, for constructors you cannot do that since you do not have a name. I tried using __ctor:

  template C ()
  {
      this (int i)
      {
  ·······
      }
  }

  class A
  {
      mixin C f;
      alias __ctor = f.__ctor;   // alias `test.A.__ctor` is not a
                                 //   constructor; identifiers starting
                                 //   with `__` are reserved for the
implementation
  ····
      this ()
      {
      }
  }

  void main ()
  {
      auto a = new A(3);
  }

But get the above mentioned error. The solution would be to allow the usage of __ctor in this situation.

--
September 17, 2020
https://issues.dlang.org/show_bug.cgi?id=3332

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |robert@octarineparrot.com

--- Comment #9 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
*** Issue 7206 has been marked as a duplicate of this issue. ***

--
September 17, 2020
https://issues.dlang.org/show_bug.cgi?id=3332

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ralph.bariz@gmail.com

--- Comment #10 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
*** Issue 17055 has been marked as a duplicate of this issue. ***

--
September 17, 2020
https://issues.dlang.org/show_bug.cgi?id=3332

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com

--- Comment #11 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
*** Issue 8228 has been marked as a duplicate of this issue. ***

--
November 16, 2022
https://issues.dlang.org/show_bug.cgi?id=3332

--- Comment #12 from RazvanN <razvan.nitu1305@gmail.com> ---
(In reply to Jacob Carlborg from comment #6)
> I might not have really understood how mixins worked back when I reported this issue so it might not be an issue.
> 
> There is one problem with this though. As far as I know you cannot alias a constructor to bring the two constructors to the same overload set.

There is a workaround:

template C ()
{
    this (int i)
    {
    }
}

class A
{
    mixin C f;
    this ()
    {
    }
    alias __ctor = f.__ctor;
}

void main ()
{
    auto a = new A(3);
}

It seems that the __ctor alias works only if the symbol is already defined.

--
November 16, 2022
https://issues.dlang.org/show_bug.cgi?id=3332

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

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

--- Comment #13 from Dlang Bot <dlang-bot@dlang.rocks> ---
@RazvanN7 created dlang/dmd pull request #14644 "Fix Issue 3332 - Mixin a constructor with a construct already present fails" fixing this issue:

- Fix Issue 3332 - Mixin a constructor with a construct already present fails

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

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

--
« First   ‹ Prev
1 2